Add missing cleanup in exec_file_locate_attach

exec_file_locate_attach allocates memory for full_exec_path (using
either exec_file_find, source_full_path_of or xstrdup) but this
memory is never freed.  This commit adds the necessary cleanup.

gdb/ChangeLog:

	* exec.c (exec_file_locate_attach): Add missing cleanup.
This commit is contained in:
Gary Benson 2016-02-17 14:38:36 +00:00
parent b3e3e0b781
commit 88178e828a
2 changed files with 9 additions and 0 deletions

View File

@ -1,3 +1,7 @@
2016-02-17 Gary Benson <gbenson@redhat.com>
* exec.c (exec_file_locate_attach): Add missing cleanup.
2016-02-16 Don Breazeal <donb@codesourcery.com> 2016-02-16 Don Breazeal <donb@codesourcery.com>
PR remote/19496 PR remote/19496

View File

@ -141,6 +141,7 @@ void
exec_file_locate_attach (int pid, int from_tty) exec_file_locate_attach (int pid, int from_tty)
{ {
char *exec_file, *full_exec_path = NULL; char *exec_file, *full_exec_path = NULL;
struct cleanup *old_chain;
/* Do nothing if we already have an executable filename. */ /* Do nothing if we already have an executable filename. */
exec_file = (char *) get_exec_file (0); 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); full_exec_path = xstrdup (exec_file);
} }
old_chain = make_cleanup (xfree, full_exec_path);
exec_file_attach (full_exec_path, from_tty); exec_file_attach (full_exec_path, from_tty);
symbol_file_add_main (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. /* Set FILENAME as the new exec file.