summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorFilipe Cabecinhas <me@filcab.net>2015-10-06 12:37:54 +0000
committerFilipe Cabecinhas <me@filcab.net>2015-10-06 12:37:54 +0000
commitb70fd8719e04209827e0ea115965e10225e98f5c (patch)
tree9701a05459d6cb54e0c1690ac4492e3af472ba63 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parent4c33a1af5d727d2810baf5b6878c3badaf5f05e1 (diff)
downloadbcm5719-llvm-b70fd8719e04209827e0ea115965e10225e98f5c.tar.gz
bcm5719-llvm-b70fd8719e04209827e0ea115965e10225e98f5c.zip
Make sure the CastInst is valid before trying to create it
Bug found with afl-fuzz. llvm-svn: 249396
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 2893eaef0fb..ce6790be713 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -3863,7 +3863,10 @@ std::error_code BitcodeReader::parseFunctionBody(Function *F) {
CurBB->getInstList().push_back(Temp);
}
} else {
- I = CastInst::Create((Instruction::CastOps)Opc, Op, ResTy);
+ auto CastOp = (Instruction::CastOps)Opc;
+ if (!CastInst::castIsValid(CastOp, Op, ResTy))
+ return error("Invalid cast");
+ I = CastInst::Create(CastOp, Op, ResTy);
}
InstructionList.push_back(I);
break;
OpenPOWER on IntegriCloud