]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/41826 (invalid read in get_constraint_for_ptr_offset)
authorRichard Guenther <rguenther@suse.de>
Wed, 20 Jan 2010 13:07:41 +0000 (13:07 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 20 Jan 2010 13:07:41 +0000 (13:07 +0000)
2010-01-20  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/41826
* tree-ssa-structalias.c (get_constraint_for_ptr_offset): Avoid
access to re-allocated vector fields.

From-SVN: r156079

gcc/ChangeLog
gcc/tree-ssa-structalias.c

index cecb2e42fcbef9968a3e3b730ac12f88c64b852d..2ba1f5d1bef0c1a308b8b024ca7e696af5d92b52 100644 (file)
@@ -1,3 +1,9 @@
+2010-01-20  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/41826
+       * tree-ssa-structalias.c (get_constraint_for_ptr_offset): Avoid
+       access to re-allocated vector fields.
+
 2010-01-18  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/42774
index 97c4fb32c73c6c50f3d16d5862483107dc0797a7..cf91502e6102697ff146ac9cd70ec4ef76167a0b 100644 (file)
@@ -2657,7 +2657,7 @@ static void
 get_constraint_for_ptr_offset (tree ptr, tree offset,
                               VEC (ce_s, heap) **results)
 {
-  struct constraint_expr *c;
+  struct constraint_expr c;
   unsigned int j, n;
   unsigned HOST_WIDE_INT rhsunitoffset, rhsoffset;
 
@@ -2708,13 +2708,13 @@ get_constraint_for_ptr_offset (tree ptr, tree offset,
   for (j = 0; j < n; j++)
     {
       varinfo_t curr;
-      c = VEC_index (ce_s, *results, j);
-      curr = get_varinfo (c->var);
+      c = *VEC_index (ce_s, *results, j);
+      curr = get_varinfo (c.var);
 
-      if (c->type == ADDRESSOF
+      if (c.type == ADDRESSOF
          && !curr->is_full_var)
        {
-         varinfo_t temp, curr = get_varinfo (c->var);
+         varinfo_t temp, curr = get_varinfo (c.var);
 
          /* Search the sub-field which overlaps with the
             pointed-to offset.  As we deal with positive offsets
@@ -2750,15 +2750,17 @@ get_constraint_for_ptr_offset (tree ptr, tree offset,
              c2.offset = 0;
              VEC_safe_push (ce_s, heap, *results, &c2);
            }
-         c->var = temp->id;
-         c->offset = 0;
+         c.var = temp->id;
+         c.offset = 0;
        }
-      else if (c->type == ADDRESSOF
+      else if (c.type == ADDRESSOF
               /* If this varinfo represents a full variable just use it.  */
               && curr->is_full_var)
-       c->offset = 0;
+       c.offset = 0;
       else
-       c->offset = rhsoffset;
+       c.offset = rhsoffset;
+
+      VEC_replace (ce_s, *results, j, &c);
     }
 }