summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp3
-rw-r--r--llvm/test/Bitcode/Inputs/invalid-pointer-element-type.bcbin0 -> 644 bytes
-rw-r--r--llvm/test/Bitcode/invalid.test2
3 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 8141d5673bd..f11eba51e6c 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -1360,7 +1360,8 @@ std::error_code BitcodeReader::ParseTypeTableBody() {
if (Record.size() == 2)
AddressSpace = Record[1];
ResultTy = getTypeByID(Record[0]);
- if (!ResultTy)
+ if (!ResultTy ||
+ !PointerType::isValidElementType(ResultTy))
return Error("Invalid type");
ResultTy = PointerType::get(ResultTy, AddressSpace);
break;
diff --git a/llvm/test/Bitcode/Inputs/invalid-pointer-element-type.bc b/llvm/test/Bitcode/Inputs/invalid-pointer-element-type.bc
new file mode 100644
index 00000000000..f9649e66429
--- /dev/null
+++ b/llvm/test/Bitcode/Inputs/invalid-pointer-element-type.bc
Binary files differ
diff --git a/llvm/test/Bitcode/invalid.test b/llvm/test/Bitcode/invalid.test
index 41173d17e5d..c18ff3d3f61 100644
--- a/llvm/test/Bitcode/invalid.test
+++ b/llvm/test/Bitcode/invalid.test
@@ -103,6 +103,8 @@ RUN: not llvm-dis -disable-output %p/Inputs/invalid-array-element-type.bc 2>&1 |
RUN: FileCheck --check-prefix=ELEMENT-TYPE %s
RUN: not llvm-dis -disable-output %p/Inputs/invalid-vector-element-type.bc 2>&1 | \
RUN: FileCheck --check-prefix=ELEMENT-TYPE %s
+RUN: not llvm-dis -disable-output %p/Inputs/invalid-pointer-element-type.bc 2>&1 | \
+RUN: FileCheck --check-prefix=ELEMENT-TYPE %s
ELEMENT-TYPE: Invalid type
OpenPOWER on IntegriCloud