aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2022-02-07 11:51:19 +0100
committerNikita Popov <npopov@redhat.com>2022-02-07 12:16:13 +0100
commit0c553bff8e76ebfbf9cd4e94ff565018ed1ff0c1 (patch)
tree7a3ee1e3ed679db456314c21bb441fee9527e46a /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parentec18030f5fc1f4a08326e65fe06c6f265a829f4c (diff)
downloadllvm-0c553bff8e76ebfbf9cd4e94ff565018ed1ff0c1.zip
llvm-0c553bff8e76ebfbf9cd4e94ff565018ed1ff0c1.tar.gz
llvm-0c553bff8e76ebfbf9cd4e94ff565018ed1ff0c1.tar.bz2
[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.
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 308986a..c24dcf0 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -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;
}
+ }
}
}