mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-28 18:30:06 +00:00
[windows] Fix leak in glob.
This commit is contained in:
@@ -45,7 +45,9 @@ utf8_to_wstring :: proc(s: string, allocator := context.temp_allocator) -> wstri
|
||||
return nil
|
||||
}
|
||||
|
||||
wstring_to_utf8 :: proc(s: wstring, N: int, allocator := context.temp_allocator) -> string {
|
||||
wstring_to_utf8 :: proc(s: wstring, N: int, allocator := context.temp_allocator) -> (res: string) {
|
||||
context.allocator = allocator
|
||||
|
||||
if N <= 0 {
|
||||
return ""
|
||||
}
|
||||
@@ -60,7 +62,7 @@ wstring_to_utf8 :: proc(s: wstring, N: int, allocator := context.temp_allocator)
|
||||
// also null terminated.
|
||||
// If N != -1 it assumes the wide string is not null terminated and the resulting string
|
||||
// will not be null terminated, we therefore have to force it to be null terminated manually.
|
||||
text := make([]byte, n+1 if N != -1 else n, allocator)
|
||||
text := make([]byte, n+1 if N != -1 else n)
|
||||
|
||||
n1 := WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, s, i32(N), raw_data(text), n, nil, nil)
|
||||
if n1 == 0 {
|
||||
@@ -74,7 +76,6 @@ wstring_to_utf8 :: proc(s: wstring, N: int, allocator := context.temp_allocator)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return string(text[:n])
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user