mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-22 03:58:16 +00:00
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
This commit is contained in:
parent
131a764e0e
commit
4bd0224887
@ -152,11 +152,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool readInt(uint32_t &Val) {
|
bool readInt(uint32_t &Val) {
|
||||||
StringRef Str = Buffer->getBuffer().slice(Cursor, Cursor+4);
|
if (Buffer->getBuffer().size() < Cursor+4) {
|
||||||
if (Str.empty()) {
|
|
||||||
errs() << "Unexpected end of memory buffer: " << Cursor+4 << ".\n";
|
errs() << "Unexpected end of memory buffer: " << Cursor+4 << ".\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
StringRef Str = Buffer->getBuffer().slice(Cursor, Cursor+4);
|
||||||
Cursor += 4;
|
Cursor += 4;
|
||||||
Val = *(const uint32_t *)(Str.data());
|
Val = *(const uint32_t *)(Str.data());
|
||||||
return true;
|
return true;
|
||||||
|
@ -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
|
// 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.
|
// required to combine the edge counts that are contained in the GCDA file.
|
||||||
for (uint32_t Line = 0; Count > 0; ++Line) {
|
for (uint32_t Line = 0; Count > 0; ++Line) {
|
||||||
|
if (Line >= Blocks.size()) {
|
||||||
|
errs() << "Unexpected number of edges.\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
GCOVBlock &Block = *Blocks[Line];
|
GCOVBlock &Block = *Blocks[Line];
|
||||||
for (size_t Edge = 0, End = Block.getNumEdges(); Edge < End; ++Edge) {
|
for (size_t Edge = 0, End = Block.getNumEdges(); Edge < End; ++Edge) {
|
||||||
if (Count == 0) {
|
if (Count == 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user