Browse Source

Fix possible leak in recursive `filepath.glob`

gingerBill 9 months ago
parent
commit
35d818bb4e
1 changed files with 7 additions and 0 deletions
  1. 7 0
      core/path/filepath/match.odin

+ 7 - 0
core/path/filepath/match.odin

@@ -246,6 +246,13 @@ glob :: proc(pattern: string, allocator := context.allocator) -> (matches: []str
 	if err != .None {
 		return
 	}
+	defer {
+		for s in m {
+			delete(s)
+		}
+		delete(m)
+	}
+
 	dmatches := make([dynamic]string, 0, 0)
 	for d in m {
 		dmatches, err = _glob(d, file, &dmatches)