From f28e97add6ff7b71eac77352dccbd06bb988ab25 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Wed, 24 Jun 2026 19:14:41 +0200 Subject: [PATCH] Fixed incorrect deallocation order on Windows --- lib/cli/args_windows.q | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/cli/args_windows.q b/lib/cli/args_windows.q index 666da12..a4450ec 100644 --- a/lib/cli/args_windows.q +++ b/lib/cli/args_windows.q @@ -9,9 +9,10 @@ args() -> ![]string { args := new(string, argc) loop i := 0..args.len { - length := kernel32.WideCharToMultiByte(io.utf8, 0, wargv[i+1], -1, 0, 0, 0, 0) - 1 - args[i] = mem.alloc(length as uint) - kernel32.WideCharToMultiByte(io.utf8, 0, wargv[i+1], -1, args[i].ptr, length, 0, 0) + length := kernel32.WideCharToMultiByte(io.utf8, 0, wargv[i+1], -1, 0, 0, 0, 0) - 1 as uint + // TODO: Memory leak that needs to be removed once the type system has been fully implemented + args[i] = string{ptr: mem.rawAlloc(length), len: length} + kernel32.WideCharToMultiByte(io.utf8, 0, wargv[i+1], -1, args[i].ptr, length as int32, 0, 0) } kernel32.LocalFree(wargv) -- 2.51.2