After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 675857 - Reference leaks using PyObject_Repr
Reference leaks using PyObject_Repr
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: gobject
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2012-05-11 04:06 UTC by Simon Feltman
Modified: 2012-07-11 05:23 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Added DECREF's for PyObject_Repr and PyObject_Str (12.61 KB, patch)
2012-07-11 02:20 UTC, Simon Feltman
none Details | Review

Description Simon Feltman 2012-05-11 04:06:48 UTC
While reading code I noticed the following pattern seems to be used in a bunch of places throughout the pygobject bindings:

 PYGLIB_PyUnicode_AsString(PyObject_Repr((PyObject*)self))

Mostly used as a parameter for exception messages. The problem is PyObject_Repr returns a reference to a new value which is lost and never DECREF'd. A simple grep and read through usage of PyObject_Str throughout the code base reveals some occasions where returns occur before the result is DECREF'd as well.
Comment 1 Simon Feltman 2012-07-11 02:20:13 UTC
Created attachment 218498 [details] [review]
Added DECREF's for PyObject_Repr and PyObject_Str

Fixed or verified all calls to PyObject_Repr or PyObject_Str are properly DECREF'd.
Comment 2 Martin Pitt 2012-07-11 04:22:32 UTC
Thanks Simon! There was a typo (extra parenthesis) and a missing argument to PYGLIB_PyUnicode_AsString() in gobjectmodule.c, but those were trivial to fix. I pushed the patch with these corrections and a slightly improved changelog ("what does it fix" in the title).
Comment 3 Simon Feltman 2012-07-11 05:23:39 UTC
Ah yes thanks. I had fixed the things mentioned locally after running 'make check' but forgot to create a new patch that included it.