Skip to content

Commit 63f99ee

Browse files
committed
[llvm-debuginfo-analyzer] Fix parsing of instructions beyond section contents
1 parent 8832a59 commit 63f99ee

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,13 @@ Error LVBinaryReader::createInstructions(LVScope *Scope,
433433

434434
ArrayRef<uint8_t> Bytes = arrayRefFromStringRef(*SectionContentsOrErr);
435435
uint64_t Offset = Address - SectionAddress;
436+
if (Offset > Bytes.size()) {
437+
LLVM_DEBUG({
438+
dbgs() << "offset (" << hexValue(Offset) << ") is beyond section size ("
439+
<< hexValue(Bytes.size()) << "); malformed input?\n";
440+
});
441+
return Error::success();
442+
}
436443
uint8_t const *Begin = Bytes.data() + Offset;
437444
uint8_t const *End = Bytes.data() + Offset + Size;
438445

0 commit comments

Comments
 (0)