llvm.org GIT mirror llvm / fdb28cd
Make sure the CastInst is valid before trying to create it Bug found with afl-fuzz. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249396 91177308-0d34-0410-b5e6-96231b3b80d8 Filipe Cabecinhas 4 years ago
3 changed file(s) with 9 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
38623862 CurBB->getInstList().push_back(Temp);
38633863 }
38643864 } else {
3865 I = CastInst::Create((Instruction::CastOps)Opc, Op, ResTy);
3865 auto CastOp = (Instruction::CastOps)Opc;
3866 if (!CastInst::castIsValid(CastOp, Op, ResTy))
3867 return error("Invalid cast");
3868 I = CastInst::Create(CastOp, Op, ResTy);
38663869 }
38673870 InstructionList.push_back(I);
38683871 break;
112112
113113 ELEMENT-TYPE: Invalid type
114114
115 RUN: not llvm-dis -disable-output %p/Inputs/invalid-cast.bc 2>&1 | \
116 RUN: FileCheck --check-prefix=INVALID-CAST %s
117
118 INVALID-CAST: Invalid cast
119
115120 RUN: not llvm-dis -disable-output %p/Inputs/invalid-array-op-not-2nd-to-last.bc 2>&1 | \
116121 RUN: FileCheck --check-prefix=ARRAY-NOT-2LAST %s
117122