btrace: Fix memory leak in btrace_clear.
[deliverable/binutils-gdb.git] / gdb / main.c
index f5387b6fe254773f171caf8bec25c048db6223cb..df4b1110d6b59cb9316c2c51bd93141102a4d632 100644 (file)
@@ -545,7 +545,9 @@ captured_main_1 (struct captured_main_args *context)
 #endif
 
   /* Prefix warning messages with the command name.  */
-  warning_pre_print = xstrprintf ("%s: warning: ", gdb_program_name);
+  gdb::unique_xmalloc_ptr<char> tmp_warn_preprint
+    (xstrprintf ("%s: warning: ", gdb_program_name));
+  warning_pre_print = tmp_warn_preprint.get ();
 
   if (! getcwd (gdb_dirbuf, sizeof (gdb_dirbuf)))
     perror_warning_with_name (_("error finding working directory"));
@@ -763,7 +765,7 @@ captured_main_1 (struct captured_main_args *context)
            break;
          case 'B':
            batch_flag = batch_silent = 1;
-           gdb_stdout = ui_file_new();
+           gdb_stdout = new null_file ();
            break;
          case 'D':
            if (optarg[0] == '\0')
@@ -972,7 +974,7 @@ captured_main_1 (struct captured_main_args *context)
     }
 
   /* Set off error and warning messages with a blank line.  */
-  xfree (warning_pre_print);
+  tmp_warn_preprint.reset ();
   warning_pre_print = _("\nwarning: ");
 
   /* Read and execute the system-wide gdbinit file, if it exists.
This page took 0.024066 seconds and 4 git commands to generate.