diff options
| author | Filipe Cabecinhas <me@filcab.net> | 2016-06-05 18:43:26 +0000 |
|---|---|---|
| committer | Filipe Cabecinhas <me@filcab.net> | 2016-06-05 18:43:26 +0000 |
| commit | fc2a3c98e959be27e87d8b09b6579fc4fb0381d8 (patch) | |
| tree | a223765f4e87a6b4d592ac62b7082f0d7191a4e6 | |
| parent | 2849b48fea5c2fd011c2ae40bf3f31b60bfb8ab4 (diff) | |
| download | bcm5719-llvm-fc2a3c98e959be27e87d8b09b6579fc4fb0381d8.tar.gz bcm5719-llvm-fc2a3c98e959be27e87d8b09b6579fc4fb0381d8.zip | |
[BitCode] Diagnose GEPs with no indices
llvm-svn: 271849
| -rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 3 | ||||
| -rw-r--r-- | llvm/test/Bitcode/Inputs/invalid-gep-no-operands.bc | bin | 0 -> 452 bytes | |||
| -rw-r--r-- | llvm/test/Bitcode/invalid.test | 5 |
3 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 91eb3f603f2..c66b60681e5 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -3090,6 +3090,9 @@ std::error_code BitcodeReader::parseConstants() { return error("Explicit gep operator type does not match pointee type " "of pointer operand"); + if (Elts.size() < 1) + return error("Invalid gep with no operands"); + ArrayRef<Constant *> Indices(Elts.begin() + 1, Elts.end()); V = ConstantExpr::getGetElementPtr(PointeeType, Elts[0], Indices, BitCode == diff --git a/llvm/test/Bitcode/Inputs/invalid-gep-no-operands.bc b/llvm/test/Bitcode/Inputs/invalid-gep-no-operands.bc Binary files differnew file mode 100644 index 00000000000..699c8b5c9a0 --- /dev/null +++ b/llvm/test/Bitcode/Inputs/invalid-gep-no-operands.bc diff --git a/llvm/test/Bitcode/invalid.test b/llvm/test/Bitcode/invalid.test index 43704639279..321c7a9fc77 100644 --- a/llvm/test/Bitcode/invalid.test +++ b/llvm/test/Bitcode/invalid.test @@ -217,3 +217,8 @@ RUN: not llvm-dis -disable-output %p/Inputs/invalid-void-constant.bc 2>&1 | \ RUN: FileCheck --check-prefix=VOID-CONSTANT-TYPE %s VOID-CONSTANT-TYPE: Invalid constant type + +RUN: not llvm-dis -disable-output %p/Inputs/invalid-gep-no-operands.bc 2>&1 | \ +RUN: FileCheck --check-prefix=GEP-NO-OPERANDS %s + +GEP-NO-OPERANDS: Invalid gep with no operands |

