Turn assertion into bitcode reading error
authorDavid Blaikie <dblaikie@gmail.com>
Fri, 13 Mar 2015 21:03:34 +0000 (21:03 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Fri, 13 Mar 2015 21:03:34 +0000 (21:03 +0000)
I don't think we test invalid bitcode records in any detail, so no test
here - just a change for consistency with existing error checks in
surrounding code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232215 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Bitcode/Reader/BitcodeReader.cpp

index c4e070cd17bb8f9c8c834d1ca5ff47a216ef8049..33b02f912f0cd361f533bfc39c4ced97d31062f2 100644 (file)
@@ -3126,8 +3126,8 @@ std::error_code BitcodeReader::ParseFunctionBody(Function *F) {
       }
 
       I = GetElementPtrInst::Create(BasePtr, GEPIdx);
-      (void)Ty;
-      assert(!Ty || Ty == cast<GetElementPtrInst>(I)->getSourceElementType());
+      if (Ty && Ty != cast<GetElementPtrInst>(I)->getSourceElementType())
+        return Error("Invalid record");
       InstructionList.push_back(I);
       if (InBounds)
         cast<GetElementPtrInst>(I)->setIsInBounds(true);