aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2024-08-31 15:12:47 +0100
committergingerBill <bill@gingerbill.org>2024-08-31 15:12:47 +0100
commit6ba1506aa93d86d19c4e572ec060cde0b1855268 (patch)
tree271b0e256c608ecf8e541d6d570b34141d911b9c
parentb4bdb73158d1c6ec8d3b16d2d5f956e749a98817 (diff)
Fix possible leaks in `os2.user_*` calls
-rw-r--r--core/os/os2/user.odin16
1 files changed, 10 insertions, 6 deletions
diff --git a/core/os/os2/user.odin b/core/os/os2/user.odin
index af0bc5da4..a0a7a839d 100644
--- a/core/os/os2/user.odin
+++ b/core/os/os2/user.odin
@@ -4,21 +4,23 @@ import "base:runtime"
@(require_results)
user_cache_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) {
+ TEMP_ALLOCATOR_GUARD()
+
#partial switch ODIN_OS {
case .Windows:
- dir = get_env("LocalAppData", allocator)
+ dir = get_env("LocalAppData", temp_allocator())
if dir != "" {
dir = clone_string(dir, allocator) or_return
}
case .Darwin:
- dir = get_env("HOME", allocator)
+ dir = get_env("HOME", temp_allocator())
if dir != "" {
dir = concatenate({dir, "/Library/Caches"}, allocator) or_return
}
case: // All other UNIX systems
dir = get_env("XDG_CACHE_HOME", allocator)
if dir == "" {
- dir = get_env("HOME", allocator)
+ dir = get_env("HOME", temp_allocator())
if dir == "" {
return
}
@@ -33,21 +35,23 @@ user_cache_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error
@(require_results)
user_config_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) {
+ TEMP_ALLOCATOR_GUARD()
+
#partial switch ODIN_OS {
case .Windows:
- dir = get_env("AppData", allocator)
+ dir = get_env("AppData", temp_allocator())
if dir != "" {
dir = clone_string(dir, allocator) or_return
}
case .Darwin:
- dir = get_env("HOME", allocator)
+ dir = get_env("HOME", temp_allocator())
if dir != "" {
dir = concatenate({dir, "/.config"}, allocator) or_return
}
case: // All other UNIX systems
dir = get_env("XDG_CACHE_HOME", allocator)
if dir == "" {
- dir = get_env("HOME", allocator)
+ dir = get_env("HOME", temp_allocator())
if dir == "" {
return
}