From 5ab1f877864c7ab9604321ce50091d101baca203 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 21 Oct 2001 00:14:44 +0000 Subject: Fix problem with a cast instruction that must be expanded to type 0 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@929 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bytecode/Reader/InstructionReader.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/Bytecode/Reader') diff --git a/lib/Bytecode/Reader/InstructionReader.cpp b/lib/Bytecode/Reader/InstructionReader.cpp index 58f2656559..1f4aa68f4a 100644 --- a/lib/Bytecode/Reader/InstructionReader.cpp +++ b/lib/Bytecode/Reader/InstructionReader.cpp @@ -48,6 +48,7 @@ bool BytecodeParser::ParseRawInst(const uchar *&Buf, const uchar *EndBuf, if (read_vbr(Buf, EndBuf, Result.Opcode)) return failure(true); if (read_vbr(Buf, EndBuf, Typ)) return failure(true); Result.Ty = getType(Typ); + if (Result.Ty == 0) return failure(true); if (read_vbr(Buf, EndBuf, Result.NumOperands)) return failure(true); switch (Result.NumOperands) { @@ -109,10 +110,13 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf, Value *V; switch (Raw.Opcode) { - case Instruction::Cast: - Res = new CastInst(getValue(Raw.Ty, Raw.Arg1), getType(Raw.Arg2)); + case Instruction::Cast: { + V = getValue(Raw.Ty, Raw.Arg1); + const Type *Ty = getType(Raw.Arg2); + if (V == 0 || Ty == 0) { cerr << "Invalid cast!\n"; return true; } + Res = new CastInst(V, Ty); return false; - + } case Instruction::PHINode: { PHINode *PN = new PHINode(Raw.Ty); switch (Raw.NumOperands) { -- cgit v1.2.3-70-g09d2