GNOME Bugzilla – Bug 675857
Reference leaks using PyObject_Repr
Last modified: 2012-07-11 05:23:39 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.
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.
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).
Ah yes thanks. I had fixed the things mentioned locally after running 'make check' but forgot to create a new patch that included it.