From 7546295abedf0d955c5bc54be68574ea890cff15 Mon Sep 17 00:00:00 2001 From: Daniel Bertalan Date: Sun, 5 Dec 2021 07:52:53 +0100 Subject: [PATCH] LibDebug: Fix truncation in ExtendedOpcodes::SetDiscriminator The parameter of this operator is an unsigned LEB128 integer, so it can be more than 1 byte in length. If we only read 1 byte, we might mess up the offsets for the instructions following it. --- Userland/Libraries/LibDebug/Dwarf/LineProgram.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibDebug/Dwarf/LineProgram.cpp b/Userland/Libraries/LibDebug/Dwarf/LineProgram.cpp index 6758c2e2e9..df1c50b394 100644 --- a/Userland/Libraries/LibDebug/Dwarf/LineProgram.cpp +++ b/Userland/Libraries/LibDebug/Dwarf/LineProgram.cpp @@ -170,7 +170,8 @@ void LineProgram::handle_extended_opcode() } case ExtendedOpcodes::SetDiscriminator: { dbgln_if(DWARF_DEBUG, "SetDiscriminator"); - m_stream.discard_or_error(1); + size_t discriminator; + m_stream.read_LEB128_unsigned(discriminator); break; } default: