This is the mail archive of the archer@sourceware.org mailing list for the Archer 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]

[python] fix memory leak


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;


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