diff options
| author | Laytan Laats <laytanlaats@hotmail.com> | 2024-08-03 15:17:29 +0200 |
|---|---|---|
| committer | Laytan Laats <laytanlaats@hotmail.com> | 2024-08-14 01:44:37 +0200 |
| commit | 939ba4cf0882291b8b35241ef6fc266ae74e9727 (patch) | |
| tree | 1a045d6aeb5ad71f0b635e32674854e2f3fd9403 | |
| parent | f00f68ef6fcb961e548ac4b685245e7b9b5bd7de (diff) | |
os2: fix leak and always close directory
| -rw-r--r-- | core/os/os2/internal_util.odin | 2 | ||||
| -rw-r--r-- | core/os/os2/path_posix.odin | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/core/os/os2/internal_util.odin b/core/os/os2/internal_util.odin index ed65ab7e0..52e7522d1 100644 --- a/core/os/os2/internal_util.odin +++ b/core/os/os2/internal_util.odin @@ -76,7 +76,7 @@ concatenate :: proc(strings: []string, allocator: runtime.Allocator) -> (res: st for s in strings { n += len(s) } - buf := make([]byte, n) or_return + buf := make([]byte, n, allocator) or_return n = 0 for s in strings { n += copy(buf[n:], s) diff --git a/core/os/os2/path_posix.odin b/core/os/os2/path_posix.odin index 066ca1ddf..2fd289300 100644 --- a/core/os/os2/path_posix.odin +++ b/core/os/os2/path_posix.odin @@ -61,6 +61,7 @@ _remove_all :: proc(path: string) -> Error { if dir == nil { return _get_platform_error() } + defer posix.closedir(dir) for { posix.set_errno(.NONE) @@ -91,7 +92,6 @@ _remove_all :: proc(path: string) -> Error { if posix.rmdir(cpath) != .OK { return _get_platform_error() } - posix.closedir(dir) return nil } |