Opened 12 years ago
Last modified 11 years ago
#4259 new Patches
Reference leak in boost::python::function::add_to_namespace()
| Reported by: | Owned by: | Ralf W. Grosse-Kunstleve | |
|---|---|---|---|
| Milestone: | Boost 1.43.0 | Component: | python USE GITHUB | 
| Version: | Boost 1.44.0 | Severity: | Problem | 
| Keywords: | Cc: | 
Description
In libs/python/src/object/function.cpp, there is an obvious reference leak:
https://svn.boost.org/trac/boost/browser/trunk/libs/python/src/object/function.cpp?rev=60625#L444
The first branch retrieves a borrowed reference, when the seconds gets  a new reference.  This is stored in a plain PyObject*, there is no magic in some destructor.  This code is likely to leak references.
I suggest to use dict = PyObject_GetAttrString(ns, "__dict__") in all cases, and add Py_DECREF(dict) when it is no more needed.
Attachments (1)
Change History (7)
comment:1 by , 12 years ago
| Component: | None → Python | 
|---|---|
| Owner: | set to | 
by , 12 years ago
| Attachment: | 4259-fix-reference-leak.patch added | 
|---|
comment:2 by , 12 years ago
| Type: | Bugs → Patches | 
|---|
comment:3 by , 11 years ago
| Owner: | changed from to | 
|---|
comment:4 by , 11 years ago
  Note:
 See   TracTickets
 for help on using tickets.
    

The patch looks good to me