This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[patch][python] Fix reference leak on Python frame error.
- From: Phil Muldoon <pmuldoon at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Wed, 18 Sep 2013 09:25:12 +0100
- Subject: [patch][python] Fix reference leak on Python frame error.
- Authentication-results: sourceware.org; auth=none
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;
}