summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/GCOV.cpp
diff options
context:
space:
mode:
authorYuchen Wu <yuchenericwu@hotmail.com>2013-11-14 00:38:41 +0000
committerYuchen Wu <yuchenericwu@hotmail.com>2013-11-14 00:38:41 +0000
commit7981f5b86c7738939b1912a067dc2a35520096dc (patch)
tree8f9feef2a3395733fe1146bcea3e297f717b6845 /llvm/lib/IR/GCOV.cpp
parent15076d5d30788f66fc2757d415612ee001b36435 (diff)
downloadbcm5719-llvm-7981f5b86c7738939b1912a067dc2a35520096dc.tar.gz
bcm5719-llvm-7981f5b86c7738939b1912a067dc2a35520096dc.zip
llvm-cov: Slightly improved error checking.
- readInt() should check all 4 bytes can be read, not just 1. - In the event of false data in the gcno file, it was possible to index into a non-existent index of SmallVector, causing assertion error. llvm-svn: 194639
Diffstat (limited to 'llvm/lib/IR/GCOV.cpp')
-rw-r--r--llvm/lib/IR/GCOV.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/IR/GCOV.cpp b/llvm/lib/IR/GCOV.cpp
index 65ed3a5a84b..a91e88c4e0f 100644
--- a/llvm/lib/IR/GCOV.cpp
+++ b/llvm/lib/IR/GCOV.cpp
@@ -135,6 +135,10 @@ bool GCOVFunction::read(GCOVBuffer &Buff, GCOV::GCOVFormat Format) {
// This for loop adds the counts for each block. A second nested loop is
// required to combine the edge counts that are contained in the GCDA file.
for (uint32_t Line = 0; Count > 0; ++Line) {
+ if (Line >= Blocks.size()) {
+ errs() << "Unexpected number of edges.\n";
+ return false;
+ }
GCOVBlock &Block = *Blocks[Line];
for (size_t Edge = 0, End = Block.getNumEdges(); Edge < End; ++Edge) {
if (Count == 0) {
OpenPOWER on IntegriCloud