Make sure Op->getType() is a PointerType before we cast<> it.
[oota-llvm.git] / lib / Bitcode / Reader / BitcodeReader.cpp
index 7778125e2d482226a37034e86d63836b79bcc8b6..456df6dab8e410788b0aa9c0d38b92921c1440b2 100644 (file)
@@ -4065,6 +4065,8 @@ std::error_code BitcodeReader::ParseFunctionBody(Function *F) {
       Type *Ty = nullptr;
       if (OpNum + 3 == Record.size())
         Ty = getTypeByID(Record[OpNum++]);
+      if (!isa<PointerType>(Op->getType()))
+        return Error("Load operand is not a pointer type");
       if (!Ty)
         Ty = cast<PointerType>(Op->getType())->getElementType();
       else if (Ty != cast<PointerType>(Op->getType())->getElementType())