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]

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


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