aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorPatric Dexheimer <patric.dexheimer@gmail.com>2022-02-20 02:10:34 -0300
committerGitHub <noreply@github.com>2022-02-20 02:10:34 -0300
commitd7eabf571c745d86862662fb03069f2dc7ac9530 (patch)
tree8616ae7b2acd351ae0627a9b9d893fbd50fa8ee1 /core
parent31c79454449c7f033805494e26dedb49bafb1e46 (diff)
Memory Leak
`dir` will leak memory if u use it with allocators that don“t care in freeing the memory at the end ( like arenas or the temp_allocator ) , because `strings.clone` and `strings.concatenate` are not using the passed allocator.
Diffstat (limited to 'core')
-rw-r--r--core/path/filepath/path.odin5
1 files changed, 3 insertions, 2 deletions
diff --git a/core/path/filepath/path.odin b/core/path/filepath/path.odin
index d6e36f649..ba6e11044 100644
--- a/core/path/filepath/path.odin
+++ b/core/path/filepath/path.odin
@@ -284,13 +284,14 @@ rel :: proc(base_path, target_path: string, allocator := context.allocator) -> (
}
dir :: proc(path: string, allocator := context.allocator) -> string {
+ context.allocator = allocator
vol := volume_name(path)
i := len(path) - 1
for i >= len(vol) && !is_separator(path[i]) {
i -= 1
}
- dir := clean(path[len(vol) : i+1], allocator)
- defer delete(dir, allocator)
+ dir := clean(path[len(vol) : i+1])
+ defer delete(dir)
if dir == "." && len(vol) > 2 {
return strings.clone(vol)
}