diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 8e4be257a8a..ad845a75279 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2014-12-08 Doug Evans + + * python/py-objfile.c (objfpy_get_owner): Increment refcount of result. + 2014-12-08 Doug Evans * NEWS: Mention gdb.Objfile.owner. diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c index 51cf47cfffd..d90928bb300 100644 --- a/gdb/python/py-objfile.c +++ b/gdb/python/py-objfile.c @@ -93,9 +93,13 @@ objfpy_get_owner (PyObject *self, void *closure) OBJFPY_REQUIRE_VALID (obj); owner = objfile->separate_debug_objfile_backlink; - if (owner != NULL) - return objfile_to_objfile_object (owner); + { + PyObject *result = objfile_to_objfile_object (owner); + + Py_XINCREF (result); + return result; + } Py_RETURN_NONE; }