mirror of
https://github.com/odin-lang/Odin.git
synced 2025-12-29 09:24:33 +00:00
Fix memory leak in os.get_current_directory on failure on *nix systems
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user