2
0
Эх сурвалжийг харах

Fix possible leaks in `os2.user_*` calls

gingerBill 1 жил өмнө
parent
commit
6ba1506aa9
1 өөрчлөгдсөн 10 нэмэгдсэн , 6 устгасан
  1. 10 6
      core/os/os2/user.odin

+ 10 - 6
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
 			}