tree-predcom.c (determine_roots_comp): Avoid memory leak by freeing reference of...
authorBin Cheng <bin.cheng@arm.com>
Fri, 10 Nov 2017 12:46:33 +0000 (12:46 +0000)
committerBin Cheng <amker@gcc.gnu.org>
Fri, 10 Nov 2017 12:46:33 +0000 (12:46 +0000)
* tree-predcom.c (determine_roots_comp): Avoid memory leak by freeing
reference of trivial component.

From-SVN: r254625

gcc/ChangeLog
gcc/tree-predcom.c

index b82ce62fdff9f7a103a00071a499d56a5915deba..1ed540a29e3ee0144644ac0aa1d6e0588ce7376a 100644 (file)
@@ -1,3 +1,8 @@
+2017-11-10  Bin Cheng  <bin.cheng@arm.com>
+
+       * tree-predcom.c (determine_roots_comp): Avoid memory leak by freeing
+       reference of trivial component.
+
 2017-11-10  Jakub Jelinek  <jakub@redhat.com>
 
        PR bootstrap/82916
index fdb32f10529badeed770015d4ff95bca65416264..d078b96cdf088e19c8afff885fc2a84871ffb209 100644 (file)
@@ -1331,7 +1331,14 @@ determine_roots_comp (struct loop *loop,
 
   /* Trivial component.  */
   if (comp->refs.length () <= 1)
-    return;
+    {
+      if (comp->refs.length () == 1)
+       {
+         free (comp->refs[0]);
+         comp->refs.truncate (0);
+       }
+      return;
+    }
 
   comp->refs.qsort (order_drefs);
   FOR_EACH_VEC_ELT (comp->refs, i, a)