This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
[python] fix memory leak
- From: Tom Tromey <tromey at redhat dot com>
- To: Project Archer <archer at sourceware dot org>
- Date: Mon, 10 Nov 2008 10:58:07 -0700
- Subject: [python] fix memory leak
- Reply-to: Tom Tromey <tromey at redhat dot com>
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;