dominance.c fix to not access undefined memory location.
Steve Ellcey
sje@cup.hp.com
Thu Jul 12 14:13:00 GMT 2001
I was running a memory checker on GCC and noticed that the if statements
below were accessing undefined memory locations because if bn was
ex_block then bn->index would be -1 or -2 and di->dfs_order[bn->index]
would be an out-of-bounds array reference. By checking for ex_block
first we can avoid that.
2001-07-12 Steve Ellcey <sje@cup.hp.com>
* dominance.c (calc_dfs_tree_nonrec): Reverse order of tests
in if statement so we don't access undefined memory.
*** gcc/dominance.c.orig Thu Jul 12 13:59:29 2001
--- gcc/dominance.c Thu Jul 12 14:02:14 2001
*************** calc_dfs_tree_nonrec (di, bb, reverse)
*** 242,248 ****
/* If the next node BN is either already visited or a border
block the current edge is useless, and simply overwritten
with the next edge out of the current node. */
! if (di->dfs_order[bn->index] || bn == ex_block)
{
e = e->pred_next;
continue;
--- 242,248 ----
/* If the next node BN is either already visited or a border
block the current edge is useless, and simply overwritten
with the next edge out of the current node. */
! if (bn == ex_block || di->dfs_order[bn->index])
{
e = e->pred_next;
continue;
*************** calc_dfs_tree_nonrec (di, bb, reverse)
*** 253,259 ****
else
{
bn = e->dest;
! if (di->dfs_order[bn->index] || bn == ex_block)
{
e = e->succ_next;
continue;
--- 253,259 ----
else
{
bn = e->dest;
! if (bn == ex_block || di->dfs_order[bn->index])
{
e = e->succ_next;
continue;
More information about the Gcc-patches
mailing list