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]

[RFA] python/py-breakpoint.c (bppy_set_condition): Stop memory leak.


OK?

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;
 }
 

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