Opened 12 years ago

Last modified 11 years ago

#4259 new Patches

Reference leak in boost::python::function::add_to_namespace()

Reported by: Amaury Forgeot d'Arc <amauryfa@…> 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)

4259-fix-reference-leak.patch (1.3 KB ) - added by Matthew Bradbury <matt-bradbury@…> 12 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 by Steven Watanabe, 12 years ago

Component: NonePython
Owner: set to Dave Abrahams

by Matthew Bradbury <matt-bradbury@…>, 12 years ago

comment:2 by Matthew Bradbury <matt-bradbury@…>, 12 years ago

Type: BugsPatches

comment:3 by Matthew Bradbury <matt-bradbury@…>, 11 years ago

Owner: changed from Dave Abrahams to Ralf W. Grosse-Kunstleve

comment:4 by Amaury Forgeot d'Arc, 11 years ago

The patch looks good to me

comment:5 by Ralf W. Grosse-Kunstleve, 11 years ago

I'll apply the patch as soon as I get a chance. May take a couple days.

comment:6 by Ralf W. Grosse-Kunstleve, 11 years ago

Applied to svn trunk, rev. 74321

Sorry this took so long.

Note: See TracTickets for help on using tickets.