forked from OSchip/llvm-project
Make sure the CastInst is valid before trying to create it
Bug found with afl-fuzz. llvm-svn: 249396
This commit is contained in:
parent
4c33a1af5d
commit
b70fd8719e
|
@ -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;
|
||||
|
|
Binary file not shown.
|
@ -113,6 +113,11 @@ RUN: FileCheck --check-prefix=ELEMENT-TYPE %s
|
|||
|
||||
ELEMENT-TYPE: Invalid type
|
||||
|
||||
RUN: not llvm-dis -disable-output %p/Inputs/invalid-cast.bc 2>&1 | \
|
||||
RUN: FileCheck --check-prefix=INVALID-CAST %s
|
||||
|
||||
INVALID-CAST: Invalid cast
|
||||
|
||||
RUN: not llvm-dis -disable-output %p/Inputs/invalid-array-op-not-2nd-to-last.bc 2>&1 | \
|
||||
RUN: FileCheck --check-prefix=ARRAY-NOT-2LAST %s
|
||||
|
||||
|
|
Loading…
Reference in New Issue