From 0cb84726d0d96730d2878839b3794c79565e1fed Mon Sep 17 00:00:00 2001 From: norrath-hero-cn <73905273+norrath-hero-cn@users.noreply.github.com> Date: Sat, 5 Aug 2023 01:59:05 +0800 Subject: [PATCH] fixes AddressSanitizer: global-buffer-overflow in getAppFilename on windows 10 (#22380) fixes AddressSanitizer: global-buffer-overflow (cherry picked from commit 73a29d72e347817a239f097c8185842e5bdca149) --- lib/pure/os.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pure/os.nim b/lib/pure/os.nim index 4613d8b05c..ca4b4fb52e 100644 --- a/lib/pure/os.nim +++ b/lib/pure/os.nim @@ -3145,14 +3145,14 @@ proc getAppFilename*(): string {.rtl, extern: "nos$1", tags: [ReadIOEffect], noW when defined(windows): var bufsize = int32(MAX_PATH) when useWinUnicode: - var buf = newWideCString("", bufsize) + var buf = newWideCString(bufsize) while true: var L = getModuleFileNameW(0, buf, bufsize) if L == 0'i32: result = "" # error! break elif L > bufsize: - buf = newWideCString("", L) + buf = newWideCString(L) bufsize = L else: result = buf$L