2011-02-27 Michael Snyder <msnyder@vmware.com>
authorMichael Snyder <msnyder@vmware.com>
Fri, 11 Mar 2011 21:34:34 +0000 (21:34 +0000)
committerMichael Snyder <msnyder@vmware.com>
Fri, 11 Mar 2011 21:34:34 +0000 (21:34 +0000)
* python/py-breakpoint.c (bppy_get_commands): Fix memory leak.

gdb/ChangeLog
gdb/python/py-breakpoint.c

index 2181f35c80af15ab0153537fa5eda3844c690ad9..13f9b162c1dc9c60edadff90774698aa6d1c8ab9 100644 (file)
@@ -1,5 +1,7 @@
 2011-03-11  Michael Snyder  <msnyder@vmware.com>
 
+       * python/py-breakpoint.c (bppy_get_commands): Fix memory leak.
+
        * top.c (set_verbose): Assert showcmd was found.
 
 2011-03-11  Maxim Grigoriev  <maxim2405@gmail.com>
index bfad002d1ae34098a66b119f5a67b9753897f1cf..c8308b99a9dcb103fbe469ab887105cafd28dcd1 100644 (file)
@@ -489,12 +489,12 @@ bppy_get_commands (PyObject *self, void *closure)
       print_command_lines (uiout, breakpoint_commands (bp), 0);
     }
   ui_out_redirect (uiout, NULL);
-  cmdstr = ui_file_xstrdup (string_file, &length);
   GDB_PY_HANDLE_EXCEPTION (except);
 
+  cmdstr = ui_file_xstrdup (string_file, &length);
+  make_cleanup (xfree, cmdstr);
   result = PyString_Decode (cmdstr, strlen (cmdstr), host_charset (), NULL);
   do_cleanups (chain);
-  xfree (cmdstr);
   return result;
 }