From 3820f27c7c25b3d7cb14d39ab60ba4210b5c1364 Mon Sep 17 00:00:00 2001 From: Tetralux Date: Wed, 26 Aug 2020 08:25:01 +0000 Subject: [PATCH] Fix os.get_current_directory() allocator This procedure accidentally used the temporary allocator for the returned string. Use context.allocator, and the allocator parameter idiom instead. --- core/os/os_windows.odin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/os/os_windows.odin b/core/os/os_windows.odin index 72916b1e4..3aedb4e59 100644 --- a/core/os/os_windows.odin +++ b/core/os/os_windows.odin @@ -271,7 +271,7 @@ get_page_size :: proc() -> int { // The current directory is stored as a global variable in the process. @private cwd_gate := false; -get_current_directory :: proc() -> string { +get_current_directory :: proc(allocator := context.allocator) -> string { for intrinsics.atomic_xchg(&cwd_gate, true) {} sz_utf16 := win32.GetCurrentDirectoryW(0, nil); @@ -282,7 +282,7 @@ get_current_directory :: proc() -> string { intrinsics.atomic_store(&cwd_gate, false); - return win32.utf16_to_utf8(dir_buf_wstr); + return win32.utf16_to_utf8(dir_buf_wstr, allocator); } set_current_directory :: proc(path: string) -> (err: Errno) {