2011-07-21 Phil Muldoon <pmuldoon@redhat.com>
[deliverable/binutils-gdb.git] / gdb / top.c
index 58c50755c775bd8688975a371b620f4a4c46f8e4..3ffd000257544e6d3182bc6f108804a46a75e017 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -378,7 +378,10 @@ execute_command (char *p, int from_tty)
 
   /* This can happen when command_line_input hits end of file.  */
   if (p == NULL)
-    return;
+    {
+      do_cleanups (cleanup);
+      return;
+    }
 
   target_log_command (p);
 
@@ -542,7 +545,10 @@ command_loop (void)
                                    get_prompt () : (char *) NULL,
                                    instream == stdin, "prompt");
       if (command == 0)
-       return;
+       {
+         do_cleanups (old_chain);
+         return;
+       }
 
       make_command_stats_cleanup (1);
 
@@ -1127,14 +1133,17 @@ get_prompt (void)
 }
 
 void
-set_prompt (char *s)
+set_prompt (const char *s)
 {
-/* ??rehrauer: I don't know why this fails, since it looks as though
-   assignments to prompt are wrapped in calls to xstrdup...
-   if (prompt != NULL)
-     xfree (prompt);
- */
-  PROMPT (0) = xstrdup (s);
+  char *p = xstrdup (s);
+
+  xfree (PROMPT (0));
+  PROMPT (0) = p;
+
+  /* Also, free and set new_async_prompt so prompt changes sync up
+     with set/show prompt.  */
+  xfree (new_async_prompt);
+  new_async_prompt = xstrdup (PROMPT (0));
 }
 \f
 
This page took 0.025864 seconds and 4 git commands to generate.