[Boost-bugs] [Boost C++ Libraries] #4259: Reference leak in boost::python::function::add_to_namespace()

Subject: [Boost-bugs] [Boost C++ Libraries] #4259: Reference leak in boost::python::function::add_to_namespace()
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-05-26 12:58:07


#4259: Reference leak in boost::python::function::add_to_namespace()
-------------------------------------------------------+--------------------
 Reporter: Amaury Forgeot d'Arc <amauryfa@…> | Owner:
     Type: Bugs | Status: new
Milestone: Boost 1.43.0 | Component: None
  Version: Boost 1.44.0 | Severity: Problem
 Keywords: |
-------------------------------------------------------+--------------------
 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.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/4259>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:03 UTC