Index: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp =================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp @@ -794,7 +794,9 @@ resize(Idx + 1); if (Value *V = ValuePtrs[Idx]) { - assert((!Ty || Ty == V->getType()) && "Type mismatch in value table!"); + // If the types don't match, it's invalid. + if (Ty && Ty != V->getType()) + return nullptr; return V; } Index: llvm/trunk/test/Bitcode/invalid.test =================================================================== --- llvm/trunk/test/Bitcode/invalid.test +++ llvm/trunk/test/Bitcode/invalid.test @@ -93,3 +93,8 @@ RUN: FileCheck --check-prefix=INVALID-TYPE %s INVALID-TYPE: Invalid type for value + +RUN: not llvm-dis -disable-output %p/Inputs/invalid-fwdref-type-mismatch.bc 2>&1 | \ +RUN: FileCheck --check-prefix=FWDREF-TYPE %s + +FWDREF-TYPE: Invalid record