summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorFilipe Cabecinhas <me@filcab.net>2015-04-24 11:30:15 +0000
committerFilipe Cabecinhas <me@filcab.net>2015-04-24 11:30:15 +0000
commitff1e234fb8f4984e3702bbf41272b363150e634b (patch)
treec280960ad7d598fb1509dcb0b471b1f75b758931 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parentb9355045e1e11fe65095f66e38d170e989d4a93a (diff)
downloadbcm5719-llvm-ff1e234fb8f4984e3702bbf41272b363150e634b.tar.gz
bcm5719-llvm-ff1e234fb8f4984e3702bbf41272b363150e634b.zip
[BitcodeReader] Fix asserts when we read a non-vector type for insert/extract/shuffle
Added some additional checking for vector types + tests. Bug found with AFL fuzz. llvm-svn: 235710
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index a16be24a5b5..57cd1d434dc 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -3646,6 +3646,8 @@ std::error_code BitcodeReader::ParseFunctionBody(Function *F) {
if (getValueTypePair(Record, OpNum, NextValueNo, Vec) ||
getValueTypePair(Record, OpNum, NextValueNo, Idx))
return Error("Invalid record");
+ if (!Vec->getType()->isVectorTy())
+ return Error("Invalid type for value");
I = ExtractElementInst::Create(Vec, Idx);
InstructionList.push_back(I);
break;
@@ -3654,8 +3656,11 @@ std::error_code BitcodeReader::ParseFunctionBody(Function *F) {
case bitc::FUNC_CODE_INST_INSERTELT: { // INSERTELT: [ty, opval,opval,opval]
unsigned OpNum = 0;
Value *Vec, *Elt, *Idx;
- if (getValueTypePair(Record, OpNum, NextValueNo, Vec) ||
- popValue(Record, OpNum, NextValueNo,
+ if (getValueTypePair(Record, OpNum, NextValueNo, Vec))
+ return Error("Invalid record");
+ if (!Vec->getType()->isVectorTy())
+ return Error("Invalid type for value");
+ if (popValue(Record, OpNum, NextValueNo,
cast<VectorType>(Vec->getType())->getElementType(), Elt) ||
getValueTypePair(Record, OpNum, NextValueNo, Idx))
return Error("Invalid record");
@@ -3673,6 +3678,8 @@ std::error_code BitcodeReader::ParseFunctionBody(Function *F) {
if (getValueTypePair(Record, OpNum, NextValueNo, Mask))
return Error("Invalid record");
+ if (!Vec1->getType()->isVectorTy() || !Vec2->getType()->isVectorTy())
+ return Error("Invalid type for value");
I = new ShuffleVectorInst(Vec1, Vec2, Mask);
InstructionList.push_back(I);
break;
OpenPOWER on IntegriCloud