Add missing cleanup in exec_file_locate_attach
[deliverable/binutils-gdb.git] / gdb / exec.c
index 23c89c252154feba1c9293beeb140bd83850393e..0b8c0777f52c2cb54230ac78bc2a6d0c704116b7 100644 (file)
@@ -141,6 +141,7 @@ void
 exec_file_locate_attach (int pid, int from_tty)
 {
   char *exec_file, *full_exec_path = NULL;
+  struct cleanup *old_chain;
 
   /* Do nothing if we already have an executable filename.  */
   exec_file = (char *) get_exec_file (0);
@@ -170,8 +171,12 @@ exec_file_locate_attach (int pid, int from_tty)
        full_exec_path = xstrdup (exec_file);
     }
 
+  old_chain = make_cleanup (xfree, full_exec_path);
+
   exec_file_attach (full_exec_path, from_tty);
   symbol_file_add_main (full_exec_path, from_tty);
+
+  do_cleanups (old_chain);
 }
 
 /* Set FILENAME as the new exec file.
This page took 0.025402 seconds and 4 git commands to generate.