diff options
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitstreamReader.cpp | 3 | ||||
-rw-r--r-- | llvm/test/Bitcode/Inputs/invalid-array-operand-encoding.bc | bin | 0 -> 579 bytes | |||
-rw-r--r-- | llvm/test/Bitcode/invalid.test | 5 |
3 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitstreamReader.cpp b/llvm/lib/Bitcode/Reader/BitstreamReader.cpp index f57e077baa0..a103fbdf4a9 100644 --- a/llvm/lib/Bitcode/Reader/BitstreamReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitstreamReader.cpp @@ -203,6 +203,9 @@ unsigned BitstreamCursor::readRecord(unsigned AbbrevID, 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"); diff --git a/llvm/test/Bitcode/Inputs/invalid-array-operand-encoding.bc b/llvm/test/Bitcode/Inputs/invalid-array-operand-encoding.bc Binary files differnew file mode 100644 index 00000000000..f7ec2eb700a --- /dev/null +++ b/llvm/test/Bitcode/Inputs/invalid-array-operand-encoding.bc diff --git a/llvm/test/Bitcode/invalid.test b/llvm/test/Bitcode/invalid.test index 9c9d54fad6c..5cdd25387b6 100644 --- a/llvm/test/Bitcode/invalid.test +++ b/llvm/test/Bitcode/invalid.test @@ -177,3 +177,8 @@ RUN: not llvm-dis -disable-output %p/Inputs/invalid-abbrev-no-operands.bc 2>&1 | RUN: FileCheck --check-prefix=ABBREV-NO-OPS %s ABBREV-NO-OPS: Abbrev record with no operands + +RUN: not llvm-dis -disable-output %p/Inputs/invalid-array-operand-encoding.bc 2>&1 | \ +RUN: FileCheck --check-prefix=ARRAY-OP-ENC %s + +ARRAY-OP-ENC: Array element type has to be an encoding of a type |