[BitstreamReader] Make sure the Array operand type is an encoding
[oota-llvm.git] / lib / Bitcode / Reader / BitstreamReader.cpp
index 2d02549ce4ea293609aa225379e19e2b5fd41e03..a103fbdf4a93a317710d171058b9788fb1f46148 100644 (file)
@@ -200,9 +200,12 @@ unsigned BitstreamCursor::readRecord(unsigned AbbrevID,
       unsigned NumElts = ReadVBR(6);
 
       // Get the element encoding.
-      if (i+2 != e)
-       report_fatal_error("Array op not second to last");
+      if (i + 2 != e)
+        report_fatal_error("Array op not second to last");
       const BitCodeAbbrevOp &EltEnc = Abbv->getOperandInfo(++i);
+      if (!EltEnc.isEncoding())
+        report_fatal_error(
+            "Array element type has to be an encoding of a type");
       if (EltEnc.getEncoding() == BitCodeAbbrevOp::Array ||
           EltEnc.getEncoding() == BitCodeAbbrevOp::Blob)
         report_fatal_error("Array element type can't be an Array or a Blob");