aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/cli')
-rw-r--r--gdb/cli/cli-script.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index b447b44..4f44477 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -54,6 +54,9 @@ static int control_level;
struct user_args
{
struct user_args *next;
+ /* It is necessary to store a malloced copy of the command line to
+ ensure that the arguments are not overwritten before they are used. */
+ char *command;
struct
{
char *arg;
@@ -483,6 +486,7 @@ arg_cleanup (void *ignore)
_("arg_cleanup called with no user args.\n"));
user_args = user_args->next;
+ xfree (oargs->command);
xfree (oargs);
}
@@ -507,6 +511,8 @@ setup_user_args (char *p)
if (p == NULL)
return old_chain;
+ user_args->command = p = xstrdup (p);
+
while (*p)
{
char *start_arg;