From bcfd1f0c5607c4a0a231e55961baf4a5a36c8c3c Mon Sep 17 00:00:00 2001 From: Filipe Cabecinhas Date: Thu, 29 Oct 2015 23:37:28 +0000 Subject: 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 llvm-svn: 251667 --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp') diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index e23f817..d2cbe9e 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -3054,7 +3054,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); -- cgit v1.1