From 4bd0224887a8de1434186cad2f618c18dea06c0b Mon Sep 17 00:00:00 2001 From: Yuchen Wu Date: Thu, 14 Nov 2013 00:38:41 +0000 Subject: 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194639 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/GCOV.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/GCOV.h b/include/llvm/Support/GCOV.h index 469a9e3..0aa716a 100644 --- a/include/llvm/Support/GCOV.h +++ b/include/llvm/Support/GCOV.h @@ -152,11 +152,11 @@ public: } bool readInt(uint32_t &Val) { - StringRef Str = Buffer->getBuffer().slice(Cursor, Cursor+4); - if (Str.empty()) { + if (Buffer->getBuffer().size() < Cursor+4) { errs() << "Unexpected end of memory buffer: " << Cursor+4 << ".\n"; return false; } + StringRef Str = Buffer->getBuffer().slice(Cursor, Cursor+4); Cursor += 4; Val = *(const uint32_t *)(Str.data()); return true; -- cgit v1.1