diff --git a/lib/std/io/os/temp_directory.c3 b/lib/std/io/os/temp_directory.c3 index 7b03efad7..671ab4e96 100644 --- a/lib/std/io/os/temp_directory.c3 +++ b/lib/std/io/os/temp_directory.c3 @@ -122,9 +122,10 @@ fn Path? native_temp_directory(Allocator allocator) @if(env::WIN32) => @pool() { Win32_DWORD len = win32::getTempPathW(0, null); if (!len) return io::GENERAL_ERROR?; - Char16[] buff = mem::talloc_array(Char16, len + (usz)1); - if (!win32::getTempPathW(len, buff)) return io::GENERAL_ERROR?; - return path::new(allocator, string::tfrom_utf16(buff[:len])); + Char16[] buff = mem::talloc_array(Char16, len); + Win32_DWORD res = win32::getTempPathW(len, buff); + if (!res) return io::GENERAL_ERROR?; + return path::new(allocator, string::tfrom_utf16(buff[:res])); } module std::io::os @if(env::NO_LIBC); diff --git a/releasenotes.md b/releasenotes.md index 2217b7810..d33eef73b 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -60,6 +60,7 @@ - bitorder::read and bitorder::write may fail because of unaligned access #2734. - Fix `LinkedList.to_format` to properly iterate linked list for printing. - Hashing a vector would not use the entire vector in some cases. +- Fix to `temp_directory` on Windows #2762. ### Stdlib changes - Add `ThreadPool` join function to wait for all threads to finish in the pool without destroying the threads. diff --git a/test/src/test_suite_runner.c3 b/test/src/test_suite_runner.c3 index 81d20eb7b..e2cc53e17 100644 --- a/test/src/test_suite_runner.c3 +++ b/test/src/test_suite_runner.c3 @@ -704,11 +704,7 @@ fn int main(String[] args) context.start_cwd = path::tcwd()!!; context.print_mutex.init()!!; - $if env::WIN32: - context.test_root = context.start_cwd; - $else - context.test_root = path::temp_directory(mem)!!; - $endif + context.test_root = path::temp_directory(mem)!!; Path? path = args[1].to_tpath(); if (catch path) arg_error_exit(appname, "Invalid compiler path: %s", args[1]);