{"thread":{"id":"25254","subject":"[PATCH] wt-status.c: don't leak directory entries when processing untracked,ignored","startedAt":"2010-09-27T02:49:13Z","lastAt":"2010-09-27T22:19:36Z","messageCount":2,"participants":["Brandon Casey","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"151778","messageId":"1285555753-15858-1-git-send-email-drafnel@gmail.com","threadId":"25254","inReplyTo":null,"subject":"[PATCH] wt-status.c: don't leak directory entries when processing untracked,ignored","fromName":"Brandon Casey","fromEmail":"drafnel@gmail.com","sentAt":"2010-09-27T02:49:13Z","receivedAt":"2010-09-27T02:49:13Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"When iterating through the list of directory entries, searching for\nuntracked entries, only the entries added to the string_list were free'd.\nThe rest (tracked or not matching the pathspec) were leaked.\n\nDitto for the \"ignored\" loop.\n\nRearrange the loops so that all entries are free'd.\n\nSigned-off-by: Brandon Casey <drafnel@gmail.com>\n---\n wt-status.c |   16 ++++++----------\n 1 files changed, 6 insertions(+), 10 deletions(-)\n\ndiff --git a/wt-status.c b/wt-status.c\nindex 54b6b03..fc2438f 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -390,11 +390,9 @@ static void wt_status_collect_untracked(struct wt_status *s)\n \tfill_directory(&dir, s->pathspec);\n \tfor (i = 0; i < dir.nr; i++) {\n \t\tstruct dir_entry *ent = dir.entries[i];\n-\t\tif (!cache_name_is_other(ent->name, ent->len))\n-\t\t\tcontinue;\n-\t\tif (!match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL))\n-\t\t\tcontinue;\n-\t\tstring_list_insert(&s->untracked, ent->name);\n+\t\tif (cache_name_is_other(ent->name, ent->len) &&\n+\t\t    match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL))\n+\t\t\tstring_list_insert(&s->untracked, ent->name);\n \t\tfree(ent);\n \t}\n \n@@ -404,11 +402,9 @@ static void wt_status_collect_untracked(struct wt_status *s)\n \t\tfill_directory(&dir, s->pathspec);\n \t\tfor (i = 0; i < dir.nr; i++) {\n \t\t\tstruct dir_entry *ent = dir.entries[i];\n-\t\t\tif (!cache_name_is_other(ent->name, ent->len))\n-\t\t\t\tcontinue;\n-\t\t\tif (!match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL))\n-\t\t\t\tcontinue;\n-\t\t\tstring_list_insert(&s->ignored, ent->name);\n+\t\t\tif (cache_name_is_other(ent->name, ent->len) &&\n+\t\t\t    match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL))\n+\t\t\t\tstring_list_insert(&s->ignored, ent->name);\n \t\t\tfree(ent);\n \t\t}\n \t}\n-- \n1.7.3.1.geb284\n"},{"id":"151858","messageId":"7vmxr2x213.fsf@alter.siamese.dyndns.org","threadId":"25254","inReplyTo":"1285555753-15858-1-git-send-email-drafnel@gmail.com","subject":"Re: [PATCH] wt-status.c: don't leak directory entries when processing untracked,ignored","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-09-27T22:19:36Z","receivedAt":"2010-09-27T22:19:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks.\n"}]}