diff --git a/core/os/os_darwin.odin b/core/os/os_darwin.odin index 456ac1d76..2d8a871c1 100644 --- a/core/os/os_darwin.odin +++ b/core/os/os_darwin.odin @@ -701,6 +701,7 @@ get_current_directory :: proc() -> string { return string(cwd) } if Errno(get_last_error()) != ERANGE { + delete(buf) return "" } resize(&buf, len(buf)+page_size) diff --git a/core/os/os_freebsd.odin b/core/os/os_freebsd.odin index eacbae97a..0ab48efaf 100644 --- a/core/os/os_freebsd.odin +++ b/core/os/os_freebsd.odin @@ -651,6 +651,7 @@ get_current_directory :: proc() -> string { return string(cwd) } if Errno(get_last_error()) != ERANGE { + delete(buf) return "" } resize(&buf, len(buf)+page_size) diff --git a/core/os/os_linux.odin b/core/os/os_linux.odin index 6f2196504..1a66f7704 100644 --- a/core/os/os_linux.odin +++ b/core/os/os_linux.odin @@ -823,6 +823,7 @@ get_current_directory :: proc() -> string { return strings.string_from_nul_terminated_ptr(&buf[0], len(buf)) } if _get_errno(res) != ERANGE { + delete(buf) return "" } resize(&buf, len(buf)+page_size) diff --git a/core/os/os_openbsd.odin b/core/os/os_openbsd.odin index 3423c1692..75ad19c46 100644 --- a/core/os/os_openbsd.odin +++ b/core/os/os_openbsd.odin @@ -649,6 +649,7 @@ get_current_directory :: proc() -> string { return string(cwd) } if Errno(get_last_error()) != ERANGE { + delete(buf) return "" } resize(&buf, len(buf) + MAX_PATH)