aboutsummaryrefslogtreecommitdiff
path: root/gdb/exec.c
diff options
context:
space:
mode:
authorGary Benson <gbenson@redhat.com>2016-02-17 14:38:36 +0000
committerGary Benson <gbenson@redhat.com>2016-02-17 16:47:11 +0000
commit88178e828a0d1af133c19d6165e4d5ee59304adf (patch)
treee7fad247c76fe4c4f09767b960c07ffbf06b7eb5 /gdb/exec.c
parentb3e3e0b7813cda26829ddf73ba3f2d98bb391720 (diff)
downloadgdb-88178e828a0d1af133c19d6165e4d5ee59304adf.zip
gdb-88178e828a0d1af133c19d6165e4d5ee59304adf.tar.gz
gdb-88178e828a0d1af133c19d6165e4d5ee59304adf.tar.bz2
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.
Diffstat (limited to 'gdb/exec.c')
-rw-r--r--gdb/exec.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/gdb/exec.c b/gdb/exec.c
index 23c89c2..0b8c077 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -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.