Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit b0ed17b

Browse files
committed
Don't assert if materializing before seeing any function bodies
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@251667 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 57ece5c commit b0ed17b

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

lib/Bitcode/Reader/BitcodeReader.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3054,7 +3054,9 @@ std::error_code BitcodeReader::rememberAndSkipFunctionBodies() {
30543054

30553055
if (Stream.AtEndOfStream()) return error("Could not find function in stream");
30563056

3057-
assert(SeenFirstFunctionBody);
3057+
if (!SeenFirstFunctionBody)
3058+
return error("Trying to materialize functions before seeing function blocks");
3059+
30583060
// An old bitcode file with the symbol table at the end would have
30593061
// finished the parse greedily.
30603062
assert(SeenValueSymbolTable);
548 Bytes
Binary file not shown.

test/Bitcode/invalid.test

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,3 +207,8 @@ RUN: not llvm-dis -disable-output %p/Inputs/invalid-alias-type-mismatch.bc 2>&1
207207
RUN: FileCheck --check-prefix=ALIAS-TYPE-MISMATCH %s
208208

209209
ALIAS-TYPE-MISMATCH: Alias and aliasee types don't match
210+
211+
RUN: not llvm-dis -disable-output %p/Inputs/invalid-no-function-block.bc 2>&1 | \
212+
RUN: FileCheck --check-prefix=NO-FUNCTION-BLOCK %s
213+
214+
NO-FUNCTION-BLOCK: Trying to materialize functions before seeing function blocks

0 commit comments

Comments
 (0)