From e73a1803acfad8286d775a3795caae5a2ad17488 Mon Sep 17 00:00:00 2001 From: Simon Wanner Date: Wed, 1 Nov 2023 00:41:15 +0100 Subject: [PATCH] LibJS/JIT: Avoid crashing while disassembling empty functions --- Userland/Libraries/LibJS/JIT/NativeExecutable.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibJS/JIT/NativeExecutable.cpp b/Userland/Libraries/LibJS/JIT/NativeExecutable.cpp index 1ddeffedb0..a6d0137c2b 100644 --- a/Userland/Libraries/LibJS/JIT/NativeExecutable.cpp +++ b/Userland/Libraries/LibJS/JIT/NativeExecutable.cpp @@ -79,9 +79,13 @@ void NativeExecutable::dump_disassembly([[maybe_unused]] Bytecode::Executable co auto symbol_provider = JITSymbolProvider(*this); auto mapping = m_mapping.begin(); - auto first_instruction = Bytecode::InstructionStreamIterator { executable.basic_blocks[0]->instruction_stream(), &executable }; - auto source_range = first_instruction.source_range().realize(); - dbgln("Disassembly of '{}' ({}:{}:{}):", executable.name, source_range.filename(), source_range.start.line, source_range.start.column); + if (!executable.basic_blocks.is_empty() && executable.basic_blocks[0]->size() != 0) { + auto first_instruction = Bytecode::InstructionStreamIterator { executable.basic_blocks[0]->instruction_stream(), &executable }; + auto source_range = first_instruction.source_range().realize(); + dbgln("Disassembly of '{}' ({}:{}:{}):", executable.name, source_range.filename(), source_range.start.line, source_range.start.column); + } else { + dbgln("Disassembly of '{}':", executable.name); + } while (true) { auto offset = stream.offset();