* [RFA] python/py-breakpoint.c (bppy_set_condition): Stop memory leak.
@ 2011-03-11 21:42 Michael Snyder
2011-03-11 21:57 ` Tom Tromey
0 siblings, 1 reply; 5+ messages in thread
From: Michael Snyder @ 2011-03-11 21:42 UTC (permalink / raw)
To: gdb-patches, tromey
[-- Attachment #1: Type: text/plain, Size: 5 bytes --]
OK?
[-- Attachment #2: py-breakpoint3.txt --]
[-- Type: text/plain, Size: 1110 bytes --]
2011-03-11 Michael Snyder <msnyder@vmware.com>
* python/py-breakpoint.c (bppy_set_condition): Stop memory leak.
Index: python/py-breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/python/py-breakpoint.c,v
retrieving revision 1.14
diff -u -p -r1.14 py-breakpoint.c
--- python/py-breakpoint.c 4 Feb 2011 21:54:16 -0000 1.14
+++ python/py-breakpoint.c 11 Mar 2011 21:26:29 -0000
@@ -435,6 +435,7 @@ bppy_set_condition (PyObject *self, PyOb
char *exp;
breakpoint_object *self_bp = (breakpoint_object *) self;
volatile struct gdb_exception except;
+ struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
BPPY_SET_REQUIRE_VALID (self_bp);
@@ -451,6 +452,7 @@ bppy_set_condition (PyObject *self, PyOb
exp = python_string_to_host_string (newvalue);
if (exp == NULL)
return -1;
+ make_cleanup (xfree, exp);
}
TRY_CATCH (except, RETURN_MASK_ALL)
@@ -459,6 +461,7 @@ bppy_set_condition (PyObject *self, PyOb
}
GDB_PY_SET_HANDLE_EXCEPTION (except);
+ do_cleanups (cleanups);
return 0;
}
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [RFA] python/py-breakpoint.c (bppy_set_condition): Stop memory leak.
2011-03-11 21:42 [RFA] python/py-breakpoint.c (bppy_set_condition): Stop memory leak Michael Snyder
@ 2011-03-11 21:57 ` Tom Tromey
2011-03-11 22:01 ` Michael Snyder
0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2011-03-11 21:57 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb-patches
>>>>> "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.
Tom
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFA] python/py-breakpoint.c (bppy_set_condition): Stop memory leak.
2011-03-11 21:57 ` Tom Tromey
@ 2011-03-11 22:01 ` Michael Snyder
2011-03-11 22:05 ` Tom Tromey
0 siblings, 1 reply; 5+ messages in thread
From: Michael Snyder @ 2011-03-11 22:01 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 535 bytes --]
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?
[-- Attachment #2: py-breakpoint4.txt --]
[-- Type: text/plain, Size: 655 bytes --]
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;
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-03-11 22:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-11 21:42 [RFA] python/py-breakpoint.c (bppy_set_condition): Stop memory leak Michael Snyder
2011-03-11 21:57 ` Tom Tromey
2011-03-11 22:01 ` Michael Snyder
2011-03-11 22:05 ` Tom Tromey
2011-03-11 22:16 ` Michael Snyder
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox