mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
fixes AddressSanitizer: global-buffer-overflow in getAppFilename on windows 10 (#22380)
fixes AddressSanitizer: global-buffer-overflow
This commit is contained in:
@@ -638,14 +638,14 @@ proc getAppFilename*(): string {.rtl, extern: "nos$1", tags: [ReadIOEffect], noW
|
||||
# /proc/<pid>/path/a.out (complete pathname)
|
||||
when defined(windows):
|
||||
var bufsize = int32(MAX_PATH)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user