diff options
Diffstat (limited to 'gdb/cli')
-rw-r--r-- | gdb/cli/cli-cmds.c | 10 | ||||
-rw-r--r-- | gdb/cli/cli-dump.c | 3 |
2 files changed, 10 insertions, 3 deletions
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index cf88b6dd657..6ee767320b0 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -357,6 +357,7 @@ cd_command (char *dir, int from_tty) /* Found something other than leading repetitions of "/..". */ int found_real_path; char *p; + struct cleanup *cleanup; /* If the new directory is absolute, repeat is a no-op; if relative, repeat might be useful but is more likely to be a mistake. */ @@ -366,7 +367,7 @@ cd_command (char *dir, int from_tty) dir = "~"; dir = tilde_expand (dir); - make_cleanup (xfree, dir); + cleanup = make_cleanup (xfree, dir); if (chdir (dir) < 0) perror_with_name (dir); @@ -450,6 +451,8 @@ cd_command (char *dir, int from_tty) if (from_tty) pwd_command ((char *) 0, 1); + + do_cleanups (cleanup); } /* Show the current value of the 'script-extension' option. */ @@ -1327,13 +1330,14 @@ alias_command (char *args, int from_tty) char *args2, *equals, *alias, *command; char **alias_argv, **command_argv; dyn_string_t alias_dyn_string, command_dyn_string; + struct cleanup *cleanup; static const char usage[] = N_("Usage: alias [-a] [--] ALIAS = COMMAND"); if (args == NULL || strchr (args, '=') == NULL) error (_(usage)); args2 = xstrdup (args); - make_cleanup (xfree, args2); + cleanup = make_cleanup (xfree, args2); equals = strchr (args2, '='); *equals = '\0'; alias_argv = gdb_buildargv (args2); @@ -1440,6 +1444,8 @@ alias_command (char *args, int from_tty) command_argv[command_argc - 1], class_alias, abbrev_flag, c_command->prefixlist); } + + do_cleanups (cleanup); } /* Print a list of files and line numbers which a user may choose from diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c index 529e0a0fe42..208916cab15 100644 --- a/gdb/cli/cli-dump.c +++ b/gdb/cli/cli-dump.c @@ -508,6 +508,7 @@ restore_section_callback (bfd *ibfd, asection *isec, void *args) static void restore_binary_file (char *filename, struct callback_data *data) { + struct cleanup *cleanup = make_cleanup (null_cleanup, NULL); FILE *file = fopen_with_cleanup (filename, FOPEN_RB); gdb_byte *buf; long len; @@ -553,7 +554,7 @@ restore_binary_file (char *filename, struct callback_data *data) len = target_write_memory (data->load_start + data->load_offset, buf, len); if (len != 0) warning (_("restore: memory write failed (%s)."), safe_strerror (len)); - return; + do_cleanups (cleanup); } static void |