1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 08:27:45 +00:00

LibJS/JIT: Don't crash when dissassembling an empty basic block

This commit is contained in:
Andreas Kling 2023-11-06 15:23:05 +01:00
parent e1e7e696ac
commit 7826c006c1

View file

@ -118,11 +118,13 @@ void NativeExecutable::dump_disassembly([[maybe_unused]] Bytecode::Executable co
if (mapping->bytecode_offset == 0) if (mapping->bytecode_offset == 0)
dbgln("\nBlock {}:", mapping->block_index + 1); dbgln("\nBlock {}:", mapping->block_index + 1);
if (block.size() != 0) {
VERIFY(mapping->bytecode_offset < block.size()); VERIFY(mapping->bytecode_offset < block.size());
auto const& instruction = *reinterpret_cast<Bytecode::Instruction const*>(block.data() + mapping->bytecode_offset); auto const& instruction = *reinterpret_cast<Bytecode::Instruction const*>(block.data() + mapping->bytecode_offset);
dbgln("{}:{:x} {}:", mapping->block_index + 1, mapping->bytecode_offset, instruction.to_deprecated_string(executable)); dbgln("{}:{:x} {}:", mapping->block_index + 1, mapping->bytecode_offset, instruction.to_deprecated_string(executable));
} }
} }
}
auto insn = disassembler.next(); auto insn = disassembler.next();
if (!insn.has_value()) if (!insn.has_value())