mirror of
https://github.com/odin-lang/Odin.git
synced 2026-06-04 09:44:40 +00:00
Add extra NUL termination check for string length in win32 general string convertors
This commit is contained in:
@@ -791,8 +791,10 @@ utf8_to_utf16 :: proc(s: string, allocator := context.temp_allocator) -> []u16 {
|
||||
}
|
||||
|
||||
text[n] = 0;
|
||||
|
||||
return text[:len(text)-1];
|
||||
for n >= 0 && text[n] == 0 {
|
||||
n -= 1;
|
||||
}
|
||||
return text[:n];
|
||||
}
|
||||
utf8_to_wstring :: proc(s: string, allocator := context.temp_allocator) -> Wstring {
|
||||
if res := utf8_to_utf16(s, allocator); res != nil {
|
||||
@@ -821,7 +823,10 @@ utf16_to_utf8 :: proc(s: []u16, allocator := context.temp_allocator) -> string {
|
||||
|
||||
text[n] = 0;
|
||||
|
||||
return string(text[:len(text)-1]);
|
||||
for n >= 0 && text[n] == 0 {
|
||||
n -= 1;
|
||||
}
|
||||
return string(text[:n]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user