* [PATCH] wt-status.c: don't leak directory entries when processing untracked,ignored
@ 2010-09-27 2:49 Brandon Casey
2010-09-27 22:19 ` Junio C Hamano
0 siblings, 1 reply; 2+ messages in thread
From: Brandon Casey @ 2010-09-27 2:49 UTC (permalink / raw)
To: gitster; +Cc: git, Brandon Casey
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>
---
wt-status.c | 16 ++++++----------
1 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/wt-status.c b/wt-status.c
index 54b6b03..fc2438f 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -390,11 +390,9 @@ static void wt_status_collect_untracked(struct wt_status *s)
fill_directory(&dir, s->pathspec);
for (i = 0; i < dir.nr; i++) {
struct dir_entry *ent = dir.entries[i];
- if (!cache_name_is_other(ent->name, ent->len))
- continue;
- if (!match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL))
- continue;
- string_list_insert(&s->untracked, ent->name);
+ if (cache_name_is_other(ent->name, ent->len) &&
+ match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL))
+ string_list_insert(&s->untracked, ent->name);
free(ent);
}
@@ -404,11 +402,9 @@ static void wt_status_collect_untracked(struct wt_status *s)
fill_directory(&dir, s->pathspec);
for (i = 0; i < dir.nr; i++) {
struct dir_entry *ent = dir.entries[i];
- if (!cache_name_is_other(ent->name, ent->len))
- continue;
- if (!match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL))
- continue;
- string_list_insert(&s->ignored, ent->name);
+ if (cache_name_is_other(ent->name, ent->len) &&
+ match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL))
+ string_list_insert(&s->ignored, ent->name);
free(ent);
}
}
--
1.7.3.1.geb284
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-09-27 22:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-27 2:49 [PATCH] wt-status.c: don't leak directory entries when processing untracked,ignored Brandon Casey
2010-09-27 22:19 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).