This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 03/28] PyObject_GetAttrString returns a new ref
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 19 Apr 2013 08:28:37 -0600
- Subject: [PATCH 03/28] PyObject_GetAttrString returns a new ref
- References: <87ehe638ww dot fsf at fleche dot redhat dot com>
This fixes a bug in py-function.c pointed out by the checker.
PyObject_GetAttrString returns a new ref, so we must decref it.
---
gdb/python/py-function.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/gdb/python/py-function.c b/gdb/python/py-function.c
index e2ba19f..395eeda 100644
--- a/gdb/python/py-function.c
+++ b/gdb/python/py-function.c
@@ -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)
--
1.8.1.4