[Bitcode] Guard against out of bounds value reference
We should make sure that the value ID is in bounds, otherwise we will assert / read out of bounds.
This commit is contained in:
@@ -2107,11 +2107,15 @@ Error BitcodeReader::parseGlobalValueSymbolTable() {
|
||||
if (!MaybeRecord)
|
||||
return MaybeRecord.takeError();
|
||||
switch (MaybeRecord.get()) {
|
||||
case bitc::VST_CODE_FNENTRY: // [valueid, offset]
|
||||
case bitc::VST_CODE_FNENTRY: { // [valueid, offset]
|
||||
unsigned ValueID = Record[0];
|
||||
if (ValueID >= ValueList.size() || !ValueList[ValueID])
|
||||
return error("Invalid value reference in symbol table");
|
||||
setDeferredFunctionInfo(FuncBitcodeOffsetDelta,
|
||||
cast<Function>(ValueList[Record[0]]), Record);
|
||||
cast<Function>(ValueList[ValueID]), Record);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user