https://github.com/charles-zablit created https://github.com/llvm/llvm-project/pull/197177
Reading `word_size` (8) bytes here would include 4 bytes of stack garbage past the struct and produce bogus error codes. >From 837a74668a01d126cecf89e8eaf274343f461f89 Mon Sep 17 00:00:00 2001 From: Charles Zablit <[email protected]> Date: Tue, 12 May 2026 13:50:39 +0100 Subject: [PATCH] [lldb][windows] fix 4-byte error-code read --- lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp index 9e11b66068381..c82841ab029aa 100644 --- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp +++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp @@ -398,10 +398,10 @@ uint32_t PlatformWindows::DoLoadImage(Process *process, } if (!token) { - // XXX(compnerd) should we use the compiler to get the sizeof(unsigned)? - uint64_t error_code = - process->ReadUnsignedIntegerFromMemory(injected_result + 2 * word_size + sizeof(unsigned), - word_size, 0, status); + // ErrorCode is a 4-byte `unsigned` field in __lldb_LoadLibraryResult. + uint64_t error_code = process->ReadUnsignedIntegerFromMemory( + injected_result + 2 * word_size + sizeof(unsigned), sizeof(unsigned), 0, + status); if (status.Fail()) { error = Status::FromErrorStringWithFormat( "LoadLibrary error: could not read error status: %s", _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
