瀏覽代碼

Fix possible leak in recursive `filepath.glob`

gingerBill 10 月之前
父節點
當前提交
e6a4f3048f
共有 1 個文件被更改,包括 7 次插入0 次删除
  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)