mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-30 03:51:56 +00:00
[BitcodeReader] Don't allow INSERTVAL/EXTRACTVAL with 0 indices
This would trigger an assertion later. Bug found with AFL fuzz. llvm-svn: 237494
This commit is contained in:
1 parent
341eda4ca7
commit
1c299d05e6
4 files changed
+20
-4
No files matched your search
@@ -3555,10 +3555,13 @@ std::error_code BitcodeReader::ParseFunctionBody(Function *F) {
|
||||
if (getValueTypePair(Record, OpNum, NextValueNo, Agg))
|
||||
return Error("Invalid record");
|
||||
|
||||
unsigned RecSize = Record.size();
|
||||
if (OpNum == RecSize)
|
||||
return Error("EXTRACTVAL: Invalid instruction with 0 indices");
|
||||
|
||||
SmallVector<unsigned, 4> EXTRACTVALIdx;
|
||||
Type *CurTy = Agg->getType();
|
||||
for (unsigned RecSize = Record.size();
|
||||
OpNum != RecSize; ++OpNum) {
|
||||
for (; OpNum != RecSize; ++OpNum) {
|
||||
bool IsArray = CurTy->isArrayTy();
|
||||
bool IsStruct = CurTy->isStructTy();
|
||||
uint64_t Index = Record[OpNum];
|
||||
@@ -3594,10 +3597,13 @@ std::error_code BitcodeReader::ParseFunctionBody(Function *F) {
|
||||
if (getValueTypePair(Record, OpNum, NextValueNo, Val))
|
||||
return Error("Invalid record");
|
||||
|
||||
unsigned RecSize = Record.size();
|
||||
if (OpNum == RecSize)
|
||||
return Error("INSERTVAL: Invalid instruction with 0 indices");
|
||||
|
||||
SmallVector<unsigned, 4> INSERTVALIdx;
|
||||
Type *CurTy = Agg->getType();
|
||||
for (unsigned RecSize = Record.size();
|
||||
OpNum != RecSize; ++OpNum) {
|
||||
for (; OpNum != RecSize; ++OpNum) {
|
||||
bool IsArray = CurTy->isArrayTy();
|
||||
bool IsStruct = CurTy->isStructTy();
|
||||
uint64_t Index = Record[OpNum];
|
||||
|
||||
Reference in new issue
Block a user