diff options
author | Filipe Cabecinhas <me@filcab.net> | 2015-05-18 22:27:11 +0000 |
---|---|---|
committer | Filipe Cabecinhas <me@filcab.net> | 2015-05-18 22:27:11 +0000 |
commit | 4708a02a78d9701d175aa134fc2b0da60e3efbd0 (patch) | |
tree | d91b9cd27ec56452d434bd184e11cfeb789d4c38 /llvm | |
parent | 09808a991c121bdce1a7ee1cf16b4c59a7c02192 (diff) | |
download | bcm5719-llvm-4708a02a78d9701d175aa134fc2b0da60e3efbd0.tar.gz bcm5719-llvm-4708a02a78d9701d175aa134fc2b0da60e3efbd0.zip |
[BitcodeReader] Make sure the type of the inserted value matches the type of the aggregate at those indices
Bug found with AFL-fuzz.
llvm-svn: 237628
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 3 | ||||
-rw-r--r-- | llvm/test/Bitcode/Inputs/invalid-inserted-value-type-mismatch.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 86c61bdf66b..70b681000a7 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -3644,6 +3644,9 @@ std::error_code BitcodeReader::ParseFunctionBody(Function *F) { CurTy = CurTy->subtypes()[0]; } + if (CurTy != Val->getType()) + return Error("Inserted value type doesn't match aggregate type"); + I = InsertValueInst::Create(Agg, Val, INSERTVALIdx); InstructionList.push_back(I); break; diff --git a/llvm/test/Bitcode/Inputs/invalid-inserted-value-type-mismatch.bc b/llvm/test/Bitcode/Inputs/invalid-inserted-value-type-mismatch.bc Binary files differnew file mode 100644 index 00000000000..81333cd6be6 --- /dev/null +++ b/llvm/test/Bitcode/Inputs/invalid-inserted-value-type-mismatch.bc diff --git a/llvm/test/Bitcode/invalid.test b/llvm/test/Bitcode/invalid.test index 7dd97a4f49a..921d4e62c04 100644 --- a/llvm/test/Bitcode/invalid.test +++ b/llvm/test/Bitcode/invalid.test @@ -142,3 +142,8 @@ RUN: not llvm-dis -disable-output %p/Inputs/invalid-load-ptr-type.bc 2>&1 | \ RUN: FileCheck --check-prefix=BAD-LOAD-PTR-TYPE %s BAD-LOAD-PTR-TYPE: Cannot load/store from pointer + +RUN: not llvm-dis -disable-output %p/Inputs/invalid-inserted-value-type-mismatch.bc 2>&1 | \ +RUN: FileCheck --check-prefix=INSERT-TYPE-MISMATCH %s + +INSERT-TYPE-MISMATCH: Inserted value type doesn't match aggregate type |