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] Fix reference leak on Python frame error.


This patch fixes a bug where we were not correctly cleaning up a newly
instanced Python object when a GDB exception error occurred while
constructing that Python object.  This patch changes the exception
handling to use gdbpy_convert_exception, and also cleans-up the leaked
reference on error.

OK?


2013-09-18  Phil Muldoon  <pmuldoon@redhat.com>

	* python/py-frame.c (frame_info_to_frame_object): Use
	gdbpy_convert_exception. Clean up Python object on failure.

--

diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c
index f960b08..58cb8a0 100644
--- a/gdb/python/py-frame.c
+++ b/gdb/python/py-frame.c
@@ -333,8 +333,12 @@ frame_info_to_frame_object (struct frame_info *frame)
 	}
       frame_obj->gdbarch = get_frame_arch (frame);
     }
-  GDB_PY_HANDLE_EXCEPTION (except);
-
+  if (except.reason < 0)
+    {
+      Py_DECREF (frame_obj);
+      gdbpy_convert_exception (except);
+      return NULL;
+    }
   return (PyObject *) frame_obj;
 }
 

	


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