This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 12/28] add decref in evpy_emit_event
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 19 Apr 2013 08:33:22 -0600
- Subject: [PATCH 12/28] add decref in evpy_emit_event
- References: <87ehe638ww dot fsf at fleche dot redhat dot com>
The checker noticed a missing decref in evpy_emit_event.
* python/py-event.c (evpy_emit_event): Decref the
result of PyObject_CallFunctionObjArgs.
---
gdb/python/py-event.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/gdb/python/py-event.c b/gdb/python/py-event.c
index 2c18e2f..afd07fe 100644
--- a/gdb/python/py-event.c
+++ b/gdb/python/py-event.c
@@ -111,16 +111,23 @@ evpy_emit_event (PyObject *event,
for (i = 0; i < PyList_Size (callback_list_copy); i++)
{
PyObject *func = PyList_GetItem (callback_list_copy, i);
+ PyObject *func_result;
if (func == NULL)
goto fail;
- if (!PyObject_CallFunctionObjArgs (func, event, NULL))
+ func_result = PyObject_CallFunctionObjArgs (func, event, NULL);
+
+ if (func_result == NULL)
{
/* Print the trace here, but keep going -- we want to try to
call all of the callbacks even if one is broken. */
gdbpy_print_stack ();
}
+ else
+ {
+ Py_DECREF (func_result);
+ }
}
Py_XDECREF (callback_list_copy);
--
1.8.1.4