From 363a06901524d9f2e60451e2ccb9322ca784570a Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Tue, 1 Aug 2017 16:06:13 +0200 Subject: [PATCH] Fix segfault in gcov.c (PR gcov-profile/81561). 2017-08-01 Martin Liska PR gcov-profile/81561 * gcov.c (unblock): Make unblocking safe as we need to preserve index correspondence of blocks and block_lists. From-SVN: r250780 --- gcc/ChangeLog | 6 ++++++ gcc/gcov.c | 10 +++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 83f9b49ba2c..09e2831eb2e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-08-01 Martin Liska + + PR gcov-profile/81561 + * gcov.c (unblock): Make unblocking safe as we need to preserve + index correspondence of blocks and block_lists. + 2017-08-01 Richard Biener PR tree-optimization/81181 diff --git a/gcc/gcov.c b/gcc/gcov.c index e324cadad82..c56bac20278 100644 --- a/gcc/gcov.c +++ b/gcc/gcov.c @@ -539,13 +539,13 @@ unblock (const block_t *u, block_vector_t &blocked, unsigned index = it - blocked.begin (); blocked.erase (it); - for (block_vector_t::iterator it2 = block_lists[index].begin (); - it2 != block_lists[index].end (); it2++) - unblock (*it2, blocked, block_lists); - for (unsigned j = 0; j < block_lists[index].size (); j++) - unblock (u, blocked, block_lists); + block_vector_t to_unblock (block_lists[index]); block_lists.erase (block_lists.begin () + index); + + for (block_vector_t::iterator it = to_unblock.begin (); + it != to_unblock.end (); it++) + unblock (*it, blocked, block_lists); } /* Find circuit going to block V, PATH is provisional seen cycle. -- 2.30.2