Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2020-11-14 21:37:03 +0300
committerJunio C Hamano <gitster@pobox.com>2020-11-17 00:45:42 +0300
commitd44e5267eaefb27521e4ed2655358b0282add239 (patch)
tree12910a7e8118a5dda5c70722ffb74ca87c3a0691 /diff-lib.c
parent898f80736c75878acc02dc55672317fcc0e0a5a6 (diff)
diff-lib: plug minor memory leaks in do_diff_cache()
do_diff_cache() builds a struct rev_info to hand to diff_cache() from scratch by initializing it using repo_init_revisions() and then replacing its diffopt and prune_data members. The diffopt member is initialized to a heap-allocated list of options, though. Release it using diff_setup_done() before overwriting it. The initial value of the prune_data member doesn't need to be released, but the copy created using copy_pathspec() does. Clear it after use. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff-lib.c')
-rw-r--r--diff-lib.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/diff-lib.c b/diff-lib.c
index f95c6de75f..68213735f4 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -536,10 +536,12 @@ int do_diff_cache(const struct object_id *tree_oid, struct diff_options *opt)
repo_init_revisions(opt->repo, &revs, NULL);
copy_pathspec(&revs.prune_data, &opt->pathspec);
+ diff_setup_done(&revs.diffopt);
revs.diffopt = *opt;
if (diff_cache(&revs, tree_oid, NULL, 1))
exit(128);
+ clear_pathspec(&revs.prune_data);
return 0;
}