This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RFC: fix ref counting in gdbpy_selected_inferior
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Mon, 20 May 2013 14:47:55 -0600
- Subject: RFC: fix ref counting in gdbpy_selected_inferior
gdbpy_selected_inferior is double-counting its returned object.
This is obvious when you realize that inferior_to_inferior_object
returns a new reference.
This patch fixes the problem by removing an incref.
Built and regtested on x86-64 Fedora 18.
Tom
* python/py-inferior.c (gdbpy_selected_inferior): Don't incref.
---
gdb/python/py-inferior.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index a93677d..26ee004 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -773,12 +773,7 @@ py_free_inferior (struct inferior *inf, void *datum)
PyObject *
gdbpy_selected_inferior (PyObject *self, PyObject *args)
{
- PyObject *inf_obj;
-
- inf_obj = inferior_to_inferior_object (current_inferior ());
- Py_INCREF (inf_obj);
-
- return inf_obj;
+ return inferior_to_inferior_object (current_inferior ());
}
int
--
1.8.1.4