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]

[patch][python PR python/13308


This patch fixes two reference leaks that Dave Malcom's cpychecker GCC
plug-in found in our code.

OK?

Cheers,

Phil
--

2011-10-18  Phil Muldoon  <pmuldoon@redhat.com>

        PR python/13308

	* python/py-breakpoint.c (gdbpy_breakpoints): Fix List reference
	leak.
	* python/py-inferior.c (gdbpy_inferiors): Fix List reference
	leak.  Delete unused variables.

--

diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
index 87265e2..daceb99 100644
--- a/gdb/python/py-breakpoint.c
+++ b/gdb/python/py-breakpoint.c
@@ -697,7 +697,7 @@ build_bp_list (struct breakpoint *b, void *arg)
 PyObject *
 gdbpy_breakpoints (PyObject *self, PyObject *args)
 {
-  PyObject *list;
+  PyObject *list, *tuple;
 
   if (bppy_live == 0)
     Py_RETURN_NONE;
@@ -715,7 +715,10 @@ gdbpy_breakpoints (PyObject *self, PyObject *args)
       return NULL;
     }
 
-  return PyList_AsTuple (list);
+  tuple = PyList_AsTuple (list);
+  Py_DECREF (list);
+
+  return tuple;
 }
 
 /* Call the "stop" method (if implemented) in the breakpoint
diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index afc3eb0..d6086dc 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -377,9 +377,7 @@ build_inferior_list (struct inferior *inf, void *arg)
 PyObject *
 gdbpy_inferiors (PyObject *unused, PyObject *unused2)
 {
-  int i = 0;
-  PyObject *list, *inferior;
-  struct inferior *inf;
+  PyObject *list, *tuple;
 
   list = PyList_New (0);
   if (!list)
@@ -391,7 +389,10 @@ gdbpy_inferiors (PyObject *unused, PyObject *unused2)
       return NULL;
     }
 
-  return PyList_AsTuple (list);
+  tuple = PyList_AsTuple (list);
+  Py_DECREF (list);
+
+  return tuple;
 }
 
 /* Membuf and memory manipulation.  */


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