mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 22:24:54 +00:00
Error out of ParseBitcodeInto(Module*) if we haven't read a Module
Summary: Without this check the following case failed: Skip a SubBlock which is not a MODULE_BLOCK_ID nor a BLOCKINFO_BLOCK_ID Got to end of file TheModule would still be == nullptr, and we would subsequentially fail when materializing the Module (assert at the start of BitcodeReader::MaterializeModule). Bug found with AFL. Reviewers: dexonsmith, rafael Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D9014 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234887 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -3063,8 +3063,12 @@ std::error_code BitcodeReader::ParseBitcodeInto(Module *M,
|
|||||||
// We expect a number of well-defined blocks, though we don't necessarily
|
// We expect a number of well-defined blocks, though we don't necessarily
|
||||||
// need to understand them all.
|
// need to understand them all.
|
||||||
while (1) {
|
while (1) {
|
||||||
if (Stream.AtEndOfStream())
|
if (Stream.AtEndOfStream()) {
|
||||||
return std::error_code();
|
if (TheModule)
|
||||||
|
return std::error_code();
|
||||||
|
// We didn't really read a proper Module.
|
||||||
|
return Error("Malformed IR file");
|
||||||
|
}
|
||||||
|
|
||||||
BitstreamEntry Entry =
|
BitstreamEntry Entry =
|
||||||
Stream.advance(BitstreamCursor::AF_DontAutoprocessAbbrevs);
|
Stream.advance(BitstreamCursor::AF_DontAutoprocessAbbrevs);
|
||||||
|
BIN
test/Bitcode/Inputs/invalid-no-proper-module.bc
Normal file
BIN
test/Bitcode/Inputs/invalid-no-proper-module.bc
Normal file
Binary file not shown.
@@ -50,3 +50,8 @@ EXTRACT-IDXS: EXTRACTVAL: Invalid type
|
|||||||
INSERT-ARRAY: INSERTVAL: Invalid array index
|
INSERT-ARRAY: INSERTVAL: Invalid array index
|
||||||
INSERT-STRUCT: INSERTVAL: Invalid struct index
|
INSERT-STRUCT: INSERTVAL: Invalid struct index
|
||||||
INSERT-IDXS: INSERTVAL: Invalid type
|
INSERT-IDXS: INSERTVAL: Invalid type
|
||||||
|
|
||||||
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-no-proper-module.bc 2>&1 | \
|
||||||
|
RUN: FileCheck --check-prefix=NO-MODULE %s
|
||||||
|
|
||||||
|
NO-MODULE: Malformed IR file
|
||||||
|
Reference in New Issue
Block a user