fix pr62009 use after free in redirect_edge_var_map_dup

The change to get the entry for the old edge before inserting the new
one was incorrect because if inserting the new one resized the table
then the pointer to the entry for the old one would become invalid.

gcc/

	* tree-ssa.c (redirect_edge_var_map_dup): insert newe before
	getting olde.

From-SVN: r213644
This commit is contained in:
Trevor Saunders 2014-08-05 19:52:08 +00:00 committed by Trevor Saunders
parent fa12e57e0c
commit 6ef6945c9c
2 changed files with 9 additions and 3 deletions

View File

@ -1,3 +1,8 @@
2014-08-05 Trevor Saunders <tsaunders@mozilla.com>
* tree-ssa.c (redirect_edge_var_map_dup): insert newe before
getting olde.
2014-08-05 Richard Biener <rguenther@suse.de>
PR rtl-optimization/61672

View File

@ -106,11 +106,12 @@ redirect_edge_var_map_dup (edge newe, edge olde)
if (!edge_var_maps)
return;
auto_vec<edge_var_map> *head = edge_var_maps->get (olde);
if (!head)
auto_vec<edge_var_map> *new_head = &edge_var_maps->get_or_insert (newe);
auto_vec<edge_var_map> *old_head = edge_var_maps->get (olde);
if (!old_head)
return;
edge_var_maps->get_or_insert (newe).safe_splice (*head);
new_head->safe_splice (*old_head);
}