Skip to content

Commit

Permalink
Don't assert if materializing before seeing any function bodies
Browse files Browse the repository at this point in the history
This assert was reachable from user input. A minimized test case (no
FUNCTION_BLOCK_ID record) is attached.

Bug found with afl-fuzz

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251910 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
filcab committed Nov 3, 2015
1 parent b6e9fa5 commit 32a2349
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/Bitcode/Reader/BitcodeReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3055,7 +3055,9 @@ std::error_code BitcodeReader::rememberAndSkipFunctionBodies() {
if (Stream.AtEndOfStream())
return error("Could not find function in stream");

assert(SeenFirstFunctionBody);
if (!SeenFirstFunctionBody)
return error("Trying to materialize functions before seeing function blocks");

// An old bitcode file with the symbol table at the end would have
// finished the parse greedily.
assert(SeenValueSymbolTable);
Expand Down
Binary file added test/Bitcode/Inputs/invalid-no-function-block.bc
Binary file not shown.
5 changes: 5 additions & 0 deletions test/Bitcode/invalid.test
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,8 @@ RUN: not llvm-dis -disable-output %p/Inputs/invalid-alias-type-mismatch.bc 2>&1
RUN: FileCheck --check-prefix=ALIAS-TYPE-MISMATCH %s

ALIAS-TYPE-MISMATCH: Alias and aliasee types don't match

RUN: not llvm-dis -disable-output %p/Inputs/invalid-no-function-block.bc 2>&1 | \
RUN: FileCheck --check-prefix=NO-FUNCTION-BLOCK %s

NO-FUNCTION-BLOCK: Trying to materialize functions before seeing function blocks

0 comments on commit 32a2349

Please sign in to comment.