summaryrefslogtreecommitdiff
path: root/builtin/add.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2017-09-05 13:04:10 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-09-06 09:06:26 (GMT)
commitfe6a01af8aa913fc23c1486251da6f6f08601816 (patch)
treea89f3e6e8fd50adc1814acb60cf840f0c61e3cc5 /builtin/add.c
parent85b81b35ff90046e5ab73808785706245a778520 (diff)
downloadgit-fe6a01af8aa913fc23c1486251da6f6f08601816.zip
git-fe6a01af8aa913fc23c1486251da6f6f08601816.tar.gz
git-fe6a01af8aa913fc23c1486251da6f6f08601816.tar.bz2
add: free leaked pathspec after add_files_to_cache()
After run_diff_files, we throw away the rev_info struct, including the pathspec that we copied into it, leaking the memory. this is probably not a big deal in practice. We usually only run this once per process, and the leak is proportional to the pathspec list we're already holding in memory. But it's still a leak, and it pollutes leak-checker output, making it harder to find important leaks. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/add.c')
-rw-r--r--builtin/add.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/builtin/add.c b/builtin/add.c
index c20548e..ef625e3 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -119,6 +119,7 @@ int add_files_to_cache(const char *prefix,
rev.diffopt.flags |= DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG;
rev.max_count = 0; /* do not compare unmerged paths with stage #2 */
run_diff_files(&rev, DIFF_RACY_IS_MODIFIED);
+ clear_pathspec(&rev.prune_data);
return !!data.add_errors;
}