summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp5
-rw-r--r--llvm/test/Bitcode/Inputs/invalid-function-argument-type.bcbin0 -> 452 bytes
-rw-r--r--llvm/test/Bitcode/invalid.test5
3 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 70b681000a7..bba29172a28 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -1402,8 +1402,11 @@ std::error_code BitcodeReader::ParseTypeTableBody() {
return Error("Invalid record");
SmallVector<Type*, 8> ArgTys;
for (unsigned i = 2, e = Record.size(); i != e; ++i) {
- if (Type *T = getTypeByID(Record[i]))
+ if (Type *T = getTypeByID(Record[i])) {
+ if (!FunctionType::isValidArgumentType(T))
+ return Error("Invalid function argument type");
ArgTys.push_back(T);
+ }
else
break;
}
diff --git a/llvm/test/Bitcode/Inputs/invalid-function-argument-type.bc b/llvm/test/Bitcode/Inputs/invalid-function-argument-type.bc
new file mode 100644
index 00000000000..b00fb03cd31
--- /dev/null
+++ b/llvm/test/Bitcode/Inputs/invalid-function-argument-type.bc
Binary files differ
diff --git a/llvm/test/Bitcode/invalid.test b/llvm/test/Bitcode/invalid.test
index c4c635e08d3..7a2dbdcc1b3 100644
--- a/llvm/test/Bitcode/invalid.test
+++ b/llvm/test/Bitcode/invalid.test
@@ -152,3 +152,8 @@ RUN: not llvm-dis -disable-output %p/Inputs/invalid-code-len-width.bc 2>&1 | \
RUN: FileCheck --check-prefix=INVALID-CODELENWIDTH %s
INVALID-CODELENWIDTH: Malformed block
+
+RUN: not llvm-dis -disable-output %p/Inputs/invalid-function-argument-type.bc 2>&1 | \
+RUN: FileCheck --check-prefix=INVALID-ARGUMENT-TYPE %s
+
+INVALID-ARGUMENT-TYPE: Invalid function argument type
OpenPOWER on IntegriCloud