From f3d4a734d89698bfa72e34dfaa2763a3d8f12e3b Mon Sep 17 00:00:00 2001 From: flysand7 Date: Sat, 13 Jul 2024 08:55:58 +1100 Subject: [PATCH] [os2/process]: Fix environment block null-terminator counting --- core/os/os2/process_windows.odin | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/core/os/os2/process_windows.odin b/core/os/os2/process_windows.odin index d6d9f0866..0dde9efe0 100644 --- a/core/os/os2/process_windows.odin +++ b/core/os/os2/process_windows.odin @@ -410,14 +410,15 @@ _get_process_user :: proc(process_handle: windows.HANDLE, allocator: runtime.All @(private) _parse_environment_block :: proc(block: [^]u16, allocator: runtime.Allocator) -> ([]string, Error) { zt_count := 0 - for idx := 0; true; idx += 1 { + for idx := 0; true; { if block[idx] == 0x0000 { zt_count += 1 + if block[idx+1] == 0x0000 { + zt_count += 1 + break + } } - if block[idx] == 0x0000 { - zt_count += 1 - break - } + idx += 1 } // Note(flysand): Each string in the environment block is terminated // by a NUL character. In addition, the environment block itself is