This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[python] [patch] PR python/13310


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;
     }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]