This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 21/28] fix refcounting in gdbpy_run_events
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 19 Apr 2013 08:40:52 -0600
- Subject: [PATCH 21/28] fix refcounting in gdbpy_run_events
- References: <87ehe638ww dot fsf at fleche dot redhat dot com>
The checker noticed a missing decref in gdbpy_run_events.
* python/python.c (gdbpy_run_events): Decref the result
of PyObject_CallObject.
---
gdb/python/python.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/gdb/python/python.c b/gdb/python/python.c
index a7b1b44..de21cdb 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -819,6 +819,8 @@ gdbpy_run_events (struct serial *scb, void *context)
while (gdbpy_event_list)
{
+ PyObject *call_result;
+
/* Dispatching the event might push a new element onto the event
loop, so we update here "atomically enough". */
struct gdbpy_event *item = gdbpy_event_list;
@@ -827,9 +829,11 @@ gdbpy_run_events (struct serial *scb, void *context)
gdbpy_event_list_end = &gdbpy_event_list;
/* Ignore errors. */
- if (PyObject_CallObject (item->event, NULL) == NULL)
+ call_result = PyObject_CallObject (item->event, NULL);
+ if (call_result == NULL)
PyErr_Clear ();
+ Py_XDECREF (call_result);
Py_DECREF (item->event);
xfree (item);
}
--
1.8.1.4