summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>2017-08-01 14:49:54 +0000
committermarxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>2017-08-01 14:49:54 +0000
commitc5697f7bce98ae101aa8d02ae1cdd9b9dd6bd0ae (patch)
tree64cde8f1ef29e1ac89028910b63dceaddb0a3672
parent11742639d196ec2df0627f9da2561866e9a3bade (diff)
downloadgcc-c5697f7bce98ae101aa8d02ae1cdd9b9dd6bd0ae.tar.gz
Fix segfault in gcov.c (PR gcov-profile/81561).
2017-08-01 Martin Liska <mliska@suse.cz> Backport from mainline 2017-07-26 Martin Liska <mliska@suse.cz> PR gcov-profile/81561 * gcov.c (unblock): Make unblocking safe as we need to preserve index correspondence of blocks and block_lists. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@250782 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/gcov.c10
2 files changed, 14 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5f10502190e..8a25d8aaa2b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2017-08-01 Martin Liska <mliska@suse.cz>
+
+ Backport from mainline
+ 2017-07-26 Martin Liska <mliska@suse.cz>
+
+ 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 <rguenther@suse.de>
PR tree-optimization/71752
diff --git a/gcc/gcov.c b/gcc/gcov.c
index 1fb505898a3..8972f4b03e9 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -499,13 +499,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.