* python/py-function.c (fnpy_init): Decref result of
authorTom Tromey <tromey@redhat.com>
Mon, 20 May 2013 20:12:04 +0000 (20:12 +0000)
committerTom Tromey <tromey@redhat.com>
Mon, 20 May 2013 20:12:04 +0000 (20:12 +0000)
PyObject_GetAttrString.

gdb/ChangeLog
gdb/python/py-function.c

index b4fb20c59f51873c8d1a15b335842501df353386..443adafb9921a1fb2efc0ea587f9946211739e23 100644 (file)
@@ -1,3 +1,8 @@
+2013-05-20  Tom Tromey  <tromey@redhat.com>
+
+       * python/py-function.c (fnpy_init): Decref result of
+       PyObject_GetAttrString.
+
 2013-05-20  Tom Tromey  <tromey@redhat.com>
 
        * python/py-threadevent.c (get_event_thread): Use
index e2ba19fce39abf1e255433689981f07496e176d2..395eeda9ad3239c32de1a3b036487e4bfb6f7ee1 100644 (file)
@@ -175,14 +175,20 @@ fnpy_init (PyObject *self, PyObject *args, PyObject *kwds)
   if (PyObject_HasAttrString (self, "__doc__"))
     {
       PyObject *ds_obj = PyObject_GetAttrString (self, "__doc__");
-      if (ds_obj && gdbpy_is_string (ds_obj))
+      if (ds_obj != NULL)
        {
-         docstring = python_string_to_host_string (ds_obj);
-         if (docstring == NULL)
+         if (gdbpy_is_string (ds_obj))
            {
-             Py_DECREF (self);
-             return -1;
+             docstring = python_string_to_host_string (ds_obj);
+             if (docstring == NULL)
+               {
+                 Py_DECREF (self);
+                 Py_DECREF (ds_obj);
+                 return -1;
+               }
            }
+
+         Py_DECREF (ds_obj);
        }
     }
   if (! docstring)