Bug found with afl-fuzz.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249396
91177308-0d34-0410-b5e6-
96231b3b80d8
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;
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