PR driver/69779: fix bogus cleanup code used by libgccjit affecting s390x
authorDavid Malcolm <dmalcolm@redhat.com>
Fri, 12 Feb 2016 18:37:35 +0000 (18:37 +0000)
committerDavid Malcolm <dmalcolm@gcc.gnu.org>
Fri, 12 Feb 2016 18:37:35 +0000 (18:37 +0000)
gcc/ChangeLog:
PR driver/69779
* gcc.c (driver::finalize): Fix cleanup of "specs".

From-SVN: r233385

gcc/ChangeLog
gcc/gcc.c

index 729034caff4be1844260c934fec106a10493769c..e783da7aadf2d7ef999cd3f3e7aa4d3b55a01df8 100644 (file)
@@ -1,3 +1,8 @@
+2016-02-12  David Malcolm  <dmalcolm@redhat.com>
+
+       PR driver/69779
+       * gcc.c (driver::finalize): Fix cleanup of "specs".
+
 2016-02-12  David Malcolm  <dmalcolm@redhat.com>
 
        PR driver/69265
index 99fa5e386a5a9b851055622f030611ce68ca410e..eaa4653227012834940b55ad2ef67620727c07b8 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -9954,8 +9954,20 @@ driver::finalize ()
   multilib_os_dir = 0;
   multiarch_dir = 0;
 
-  XDELETEVEC (specs);
-  specs = 0;
+  /* Free any specs dynamically-allocated by set_spec.
+     These will be at the head of the list, before the
+     statically-allocated ones.  */
+  if (specs)
+    {
+      while (specs != static_specs)
+       {
+         spec_list *next = specs->next;
+         free (const_cast <char *> (specs->name));
+         XDELETE (specs);
+         specs = next;
+       }
+      specs = 0;
+    }
   for (unsigned i = 0; i < ARRAY_SIZE (static_specs); i++)
     {
       spec_list *sl = &static_specs[i];