Commit bd02b3a0 by Richard Guenther Committed by Richard Biener

re PR tree-optimization/41826 (invalid read in get_constraint_for_ptr_offset)

2009-10-26  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: r153550
parent b77a0698
2009-10-26 Richard Guenther <rguenther@suse.de> 2009-10-26 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.
2009-10-26 Richard Guenther <rguenther@suse.de>
* graphite-sese-to-poly.c (check_poly_representation): Fix * graphite-sese-to-poly.c (check_poly_representation): Fix
compile without checking. compile without checking.
...@@ -2825,7 +2825,7 @@ static void ...@@ -2825,7 +2825,7 @@ static void
get_constraint_for_ptr_offset (tree ptr, tree offset, get_constraint_for_ptr_offset (tree ptr, tree offset,
VEC (ce_s, heap) **results) VEC (ce_s, heap) **results)
{ {
struct constraint_expr *c; struct constraint_expr c;
unsigned int j, n; unsigned int j, n;
HOST_WIDE_INT rhsunitoffset, rhsoffset; HOST_WIDE_INT rhsunitoffset, rhsoffset;
...@@ -2863,14 +2863,14 @@ get_constraint_for_ptr_offset (tree ptr, tree offset, ...@@ -2863,14 +2863,14 @@ get_constraint_for_ptr_offset (tree ptr, tree offset,
for (j = 0; j < n; j++) for (j = 0; j < n; j++)
{ {
varinfo_t curr; varinfo_t curr;
c = VEC_index (ce_s, *results, j); c = *VEC_index (ce_s, *results, j);
curr = get_varinfo (c->var); curr = get_varinfo (c.var);
if (c->type == ADDRESSOF if (c.type == ADDRESSOF
/* If this varinfo represents a full variable just use it. */ /* If this varinfo represents a full variable just use it. */
&& curr->is_full_var) && curr->is_full_var)
c->offset = 0; c.offset = 0;
else if (c->type == ADDRESSOF else if (c.type == ADDRESSOF
/* If we do not know the offset add all subfields. */ /* If we do not know the offset add all subfields. */
&& rhsoffset == UNKNOWN_OFFSET) && rhsoffset == UNKNOWN_OFFSET)
{ {
...@@ -2881,13 +2881,13 @@ get_constraint_for_ptr_offset (tree ptr, tree offset, ...@@ -2881,13 +2881,13 @@ get_constraint_for_ptr_offset (tree ptr, tree offset,
c2.var = temp->id; c2.var = temp->id;
c2.type = ADDRESSOF; c2.type = ADDRESSOF;
c2.offset = 0; c2.offset = 0;
if (c2.var != c->var) if (c2.var != c.var)
VEC_safe_push (ce_s, heap, *results, &c2); VEC_safe_push (ce_s, heap, *results, &c2);
temp = temp->next; temp = temp->next;
} }
while (temp); while (temp);
} }
else if (c->type == ADDRESSOF) else if (c.type == ADDRESSOF)
{ {
varinfo_t temp; varinfo_t temp;
unsigned HOST_WIDE_INT offset = curr->offset + rhsoffset; unsigned HOST_WIDE_INT offset = curr->offset + rhsoffset;
...@@ -2919,11 +2919,13 @@ get_constraint_for_ptr_offset (tree ptr, tree offset, ...@@ -2919,11 +2919,13 @@ get_constraint_for_ptr_offset (tree ptr, tree offset,
c2.offset = 0; c2.offset = 0;
VEC_safe_push (ce_s, heap, *results, &c2); VEC_safe_push (ce_s, heap, *results, &c2);
} }
c->var = temp->id; c.var = temp->id;
c->offset = 0; c.offset = 0;
} }
else else
c->offset = rhsoffset; c.offset = rhsoffset;
VEC_replace (ce_s, *results, j, &c);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment