bool DWARFUnitIndex::Header::parse(DataExtractor IndexData,
uint32_t *OffsetPtr) {
+ if (!IndexData.isValidOffsetForDataOfSize(*OffsetPtr, 16))
+ return false;
Version = IndexData.getU32(OffsetPtr);
NumColumns = IndexData.getU32(OffsetPtr);
NumUnits = IndexData.getU32(OffsetPtr);
if (!Header.parse(IndexData, &Offset))
return false;
+ if (!IndexData.isValidOffsetForDataOfSize(
+ Offset, Header.NumBuckets * (8 + 4) +
+ (2 * Header.NumUnits + 1) * 4 * Header.NumColumns))
+ return false;
+
Rows = llvm::make_unique<HashRow[]>(Header.NumBuckets);
auto Contribs =
llvm::make_unique<HashRow::SectionContribution *[]>(Header.NumUnits);