summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp2
-rw-r--r--llvm/test/Bitcode/invalid-type-for-null-constant.ll6
-rw-r--r--llvm/test/Bitcode/invalid-type-for-null-constant.ll.bcbin0 -> 900 bytes
3 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 32ae4cd9956..af906071225 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -2377,6 +2377,8 @@ Error BitcodeReader::parseConstants() {
CurTy = flattenPointerTypes(CurFullTy);
continue; // Skip the ValueList manipulation.
case bitc::CST_CODE_NULL: // NULL
+ if (CurTy->isVoidTy() || CurTy->isFunctionTy() || CurTy->isLabelTy())
+ return error("Invalid type for a constant null value");
V = Constant::getNullValue(CurTy);
break;
case bitc::CST_CODE_INTEGER: // INTEGER: [intval]
diff --git a/llvm/test/Bitcode/invalid-type-for-null-constant.ll b/llvm/test/Bitcode/invalid-type-for-null-constant.ll
new file mode 100644
index 00000000000..28756fa1823
--- /dev/null
+++ b/llvm/test/Bitcode/invalid-type-for-null-constant.ll
@@ -0,0 +1,6 @@
+; Bitcode with a CST_CODE_NULL with void type.
+
+; RUN: not llvm-dis %s.bc -o - 2>&1 | FileCheck %s
+
+; CHECK: error: Invalid type for a constant null value
+
diff --git a/llvm/test/Bitcode/invalid-type-for-null-constant.ll.bc b/llvm/test/Bitcode/invalid-type-for-null-constant.ll.bc
new file mode 100644
index 00000000000..6196ebccb9d
--- /dev/null
+++ b/llvm/test/Bitcode/invalid-type-for-null-constant.ll.bc
Binary files differ
OpenPOWER on IntegriCloud