Seems only in some cases we fault freeing an uninitialized obstack.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2011-10-26  Richard Guenther  <rguent...@suse.de>

        * lto-wrapper.c (run_gcc): Properly init/free obstack.

Index: gcc/lto-wrapper.c
===================================================================
*** gcc/lto-wrapper.c   (revision 180520)
--- gcc/lto-wrapper.c   (working copy)
*************** run_gcc (unsigned argc, char *argv[])
*** 339,345 ****
    char *list_option_full = NULL;
    const char *linker_output = NULL;
    const char *collect_gcc, *collect_gcc_options;
-   struct obstack env_obstack;
    int parallel = 0;
    int jobserver = 0;
    bool no_partition = false;
--- 339,344 ----
*************** run_gcc (unsigned argc, char *argv[])
*** 517,527 ****
--- 516,528 ----
      {
        FILE *stream = fopen (ltrans_output_file, "r");
        FILE *mstream = NULL;
+       struct obstack env_obstack;
  
        if (!stream)
        fatal_perror ("fopen: %s", ltrans_output_file);
  
        /* Parse the list of LTRANS inputs from the WPA stage.  */
+       obstack_init (&env_obstack);
        nr = 0;
        for (;;)
        {
*************** cont:
*** 574,580 ****
  
          /* Replace the .o suffix with a .ltrans.o suffix and write
             the resulting name to the LTRANS output list.  */
-         obstack_init (&env_obstack);
          obstack_grow (&env_obstack, input_name, strlen (input_name) - 2);
          obstack_grow (&env_obstack, ".ltrans.o", sizeof (".ltrans.o"));
          output_name = XOBFINISH (&env_obstack, char *);
--- 575,580 ----
*************** cont:
*** 654,662 ****
        free (output_names);
        free (input_names);
        free (list_option_full);
      }
- 
-   obstack_free (&env_obstack, NULL);
  }
  
  
--- 654,661 ----
        free (output_names);
        free (input_names);
        free (list_option_full);
+       obstack_free (&env_obstack, NULL);
      }
  }
  
  

Reply via email to