[COMMITTED] (objfpy_get_owner): Increment refcount of result.

Message ID yjt2vbll4ks1.fsf@ruffy.mtv.corp.google.com
State Committed
Headers

Commit Message

Doug Evans Dec. 9, 2014, 2:30 a.m. UTC
  Hi.

I noticed this while debugging another objfile refcount problem
(in a new patch I'm working on).

2014-12-08  Doug Evans  <dje@google.com>

	* python/py-objfile.c (objfpy_get_owner): Increment refcount of result.
  

Patch

diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
index 51cf47c..e78ceba 100644
--- a/gdb/python/py-objfile.c
+++ b/gdb/python/py-objfile.c
@@ -93,9 +94,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;
 }