[python] fix memory leak
Tom Tromey
tromey@redhat.com
Mon Nov 10 17:58:00 GMT 2008
This fixes a memory leak I noticed when looking at some Type issues.
Something like this is needed upstream.
Tom
2008-11-10 Tom Tromey <tromey@redhat.com>
* cli/cli-cmds.c (source_script): Clean up full_pathname.
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 92a59a3..e1dc88a 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -454,6 +454,7 @@ source_script (char *file, int from_tty)
files. Put the full location in 'full_pathname'. */
fd = openp (source_path, OPF_TRY_CWD_FIRST,
file, O_RDONLY, 0, &full_pathname);
+ make_cleanup (xfree, full_pathname);
/* Use the full path name, if it is found. */
if (full_pathname != NULL && fd != -1)
@@ -466,7 +467,10 @@ source_script (char *file, int from_tty)
if (from_tty)
perror_with_name (file);
else
- return;
+ {
+ do_cleanups (old_cleanups);
+ return;
+ }
}
is_python = source_python;
More information about the Archer
mailing list