wt-status.c: don't leak directory entries when processing untracked,ignored
When iterating through the list of directory entries, searching for untracked entries, only the entries added to the string_list were free'd. The rest (tracked or not matching the pathspec) were leaked. Ditto for the "ignored" loop. Rearrange the loops so that all entries are free'd. Signed-off-by: Brandon Casey <drafnel@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Brandon Casey committed
Sep 26, 2010 at 21:49 UTC
b822423ed20df158a478c9522373bffb04fa5ecc
1 file changed
+6
-10
wt-status.c
+6
-10
@@ -390,11 +390,9 @@ static void wt_status_collect_untracked(struct wt_status *s)
390
fill_directory(&dir, s->pathspec);
391
for (i = 0; i < dir.nr; i++) {
392
struct dir_entry *ent = dir.entries[i];
393
- if (!cache_name_is_other(ent->name, ent->len))
394
- continue;
395
- if (!match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL))
396
- continue;
397
- string_list_insert(&s->untracked, ent->name);
393
+ if (cache_name_is_other(ent->name, ent->len) &&
394
+ match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL))
395
+ string_list_insert(&s->untracked, ent->name);
396
free(ent);
397
}
398
@@ -404,11 +402,9 @@ static void wt_status_collect_untracked(struct wt_status *s)
402
fill_directory(&dir, s->pathspec);
403
for (i = 0; i < dir.nr; i++) {
404
struct dir_entry *ent = dir.entries[i];
407
- if (!cache_name_is_other(ent->name, ent->len))
408
- continue;
409
- if (!match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL))
410
- continue;
411
- string_list_insert(&s->ignored, ent->name);
405
+ if (cache_name_is_other(ent->name, ent->len) &&
406
+ match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL))
407
+ string_list_insert(&s->ignored, ent->name);
408
free(ent);
409
}
410
}