This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[python] [patch] PR python/13310
- From: Phil Muldoon <pmuldoon at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 20 Oct 2011 15:23:22 +0100
- Subject: [python] [patch] PR python/13310
- Reply-to: pmuldoon at redhat dot com
David Malcolm's GCC plug-in found another bug where we lose a reference.
The first case is we do not decrement "result" after a call to
"python_string_to_host_string". That function returns a xstrdup of the
string PyObject contents, and so "result" does not need to be preserved.
The second case is where we type-check the object, and if it is not a
Python string we set an exception without decrementing "result".
OK?
Cheers,
Phil
--
2011-10-20 Phil Muldoon <pmuldoon@redhat.com>
PR python/13310
* python/py-param.c (call_doc_function): Correctly deference on
function exit.
--
diff --git a/gdb/python/py-param.c b/gdb/python/py-param.c
index d68d8fb..fe31cd1 100644
--- a/gdb/python/py-param.c
+++ b/gdb/python/py-param.c
@@ -331,6 +331,7 @@ call_doc_function (PyObject *obj, PyObject *method, PyObject *arg)
if (gdbpy_is_string (result))
{
data = python_string_to_host_string (result);
+ Py_DECREF (result);
if (! data)
return NULL;
}
@@ -338,6 +339,7 @@ call_doc_function (PyObject *obj, PyObject *method, PyObject *arg)
{
PyErr_SetString (PyExc_RuntimeError,
_("Parameter must return a string value."));
+ Py_DECREF (result);
return NULL;
}