Make the utf16 conversion procedures in core:sys/windows safer by checking for memory leaks

This commit is contained in:
gingerBill
2022-05-12 13:17:58 +01:00
parent bb4f108487
commit eef44b11f3
17 changed files with 105 additions and 72 deletions
+2 -2
View File
@@ -29,7 +29,7 @@ _lookup_env :: proc(key: string, allocator: runtime.Allocator) -> (value: string
return "", false
}
value = win32.utf16_to_utf8(b[:n], allocator)
value = win32.utf16_to_utf8(b[:n], allocator) or_else ""
found = true
return
}
@@ -73,7 +73,7 @@ _environ :: proc(allocator: runtime.Allocator) -> []string {
break
}
w := ([^]u16)(p)[from:i]
append(&r, win32.utf16_to_utf8(w, allocator))
append(&r, win32.utf16_to_utf8(w, allocator) or_else "")
from = i + 1
}
}