This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] python/py-breakpoint.c (bppy_set_condition): Stop memory leak.
- From: Michael Snyder <msnyder at vmware dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Fri, 11 Mar 2011 13:54:44 -0800
- Subject: Re: [RFA] python/py-breakpoint.c (bppy_set_condition): Stop memory leak.
- References: <4D7A944E.20801@vmware.com> <m3ei6d49k1.fsf@fleche.redhat.com>
Tom Tromey wrote:
"Michael" == Michael Snyder <msnyder@vmware.com> writes:
Michael> 2011-03-11 Michael Snyder <msnyder@vmware.com>
Michael> * python/py-breakpoint.c (bppy_set_condition): Stop memory leak.
This isn't sufficient to stop the leak.
Michael> GDB_PY_SET_HANDLE_EXCEPTION (except);
This can return.
We aren't really using cleanups in "pure python" functions like this one.
You can just explicitly xfree `exp' after the TRY_CATCH.
However, note the `exp = ""' branch.
Like this?
2011-03-11 Michael Snyder <msnyder@vmware.com>
* python/py-breakpoint.c (bppy_set_condition): Stop memory leak.
Index: py-breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/python/py-breakpoint.c,v
retrieving revision 1.15
diff -u -p -r1.15 py-breakpoint.c
--- py-breakpoint.c 11 Mar 2011 21:34:34 -0000 1.15
+++ py-breakpoint.c 11 Mar 2011 21:53:40 -0000
@@ -457,6 +457,10 @@ bppy_set_condition (PyObject *self, PyOb
{
set_breakpoint_condition (self_bp->bp, exp, 0);
}
+
+ if (newvalue != Py_None)
+ xfree (exp);
+
GDB_PY_SET_HANDLE_EXCEPTION (except);
return 0;