Boost C++ Libraries: Ticket #4259: Reference leak in boost::python::function::add_to_namespace() https://svn.boost.org/trac10/ticket/4259 <p> In libs/python/src/object/function.cpp, there is an obvious reference leak: </p> <p> <a class="ext-link" href="https://svn.boost.org/trac/boost/browser/trunk/libs/python/src/object/function.cpp?rev=60625#L444"><span class="icon">​</span>https://svn.boost.org/trac/boost/browser/trunk/libs/python/src/object/function.cpp?rev=60625#L444</a> </p> <p> The first branch retrieves a borrowed reference, when the seconds gets a new reference. This is stored in a plain <code>PyObject*</code>, there is no magic in some destructor. This code is likely to leak references. </p> <p> I suggest to use <code>dict = PyObject_GetAttrString(ns, "__dict__")</code> in all cases, and add <code>Py_DECREF(dict)</code> when it is no more needed. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4259 Trac 1.4.3 Steven Watanabe Wed, 26 May 2010 13:02:29 GMT component changed; owner set https://svn.boost.org/trac10/ticket/4259#comment:1 https://svn.boost.org/trac10/ticket/4259#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Dave Abrahams</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">Python</span> </li> </ul> Ticket Matthew Bradbury <matt-bradbury@…> Sat, 30 Oct 2010 13:18:19 GMT attachment set https://svn.boost.org/trac10/ticket/4259 https://svn.boost.org/trac10/ticket/4259 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">4259-fix-reference-leak.patch</span> </li> </ul> Ticket Matthew Bradbury <matt-bradbury@…> Sat, 30 Oct 2010 13:18:38 GMT type changed https://svn.boost.org/trac10/ticket/4259#comment:2 https://svn.boost.org/trac10/ticket/4259#comment:2 <ul> <li><strong>type</strong> <span class="trac-field-old">Bugs</span> → <span class="trac-field-new">Patches</span> </li> </ul> Ticket Matthew Bradbury <matt-bradbury@…> Fri, 26 Aug 2011 14:13:33 GMT owner changed https://svn.boost.org/trac10/ticket/4259#comment:3 https://svn.boost.org/trac10/ticket/4259#comment:3 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Dave Abrahams</span> to <span class="trac-author">Ralf W. Grosse-Kunstleve</span> </li> </ul> Ticket Amaury Forgeot d'Arc Fri, 26 Aug 2011 14:27:57 GMT <link>https://svn.boost.org/trac10/ticket/4259#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4259#comment:4</guid> <description> <p> The patch looks good to me </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ralf W. Grosse-Kunstleve</dc:creator> <pubDate>Fri, 26 Aug 2011 16:27:10 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4259#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4259#comment:5</guid> <description> <p> I'll apply the patch as soon as I get a chance. May take a couple days. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ralf W. Grosse-Kunstleve</dc:creator> <pubDate>Thu, 08 Sep 2011 21:27:56 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4259#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4259#comment:6</guid> <description> <p> Applied to svn trunk, rev. 74321 </p> <p> Sorry this took so long. </p> </description> <category>Ticket</category> </item> </channel> </rss>