Browse Source

Fix utf8_to_wstring given zero bytes.

Jeroen van Rijn 1 year ago
parent
commit
164a5e587e
1 changed files with 4 additions and 1 deletions
  1. 4 1
      core/sys/windows/util.odin

+ 4 - 1
core/sys/windows/util.odin

@@ -53,8 +53,11 @@ utf8_to_utf16 :: proc(s: string, allocator := context.temp_allocator) -> []u16 {
 	return text[:n]
 	return text[:n]
 }
 }
 utf8_to_wstring :: proc(s: string, allocator := context.temp_allocator) -> wstring {
 utf8_to_wstring :: proc(s: string, allocator := context.temp_allocator) -> wstring {
-	if res := utf8_to_utf16(s, allocator); res != nil {
+	if res := utf8_to_utf16(s, allocator); len(res) > 0 {
 		return &res[0]
 		return &res[0]
+	} else {
+		delete(res, allocator)
+		return nil
 	}
 	}
 	return nil
 	return nil
 }
 }