Browse Source

checkout, read-tree: fix leak of unpack_trees_options.dir

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Elijah Newren 3 years ago committed by Junio C Hamano
parent
commit
c512d27e78
  1. 4
      builtin/checkout.c
  2. 5
      builtin/read-tree.c

4
builtin/checkout.c

@ -760,6 +760,10 @@ static int merge_working_tree(const struct checkout_opts *opts, @@ -760,6 +760,10 @@ static int merge_working_tree(const struct checkout_opts *opts,
init_tree_desc(&trees[1], tree->buffer, tree->size);

ret = unpack_trees(2, trees, &topts);
if (topts.dir) {
dir_clear(topts.dir);
FREE_AND_NULL(topts.dir);
}
clear_unpack_trees_porcelain(&topts);
if (ret == -1) {
/*

5
builtin/read-tree.c

@ -250,6 +250,11 @@ int cmd_read_tree(int argc, const char **argv, const char *cmd_prefix) @@ -250,6 +250,11 @@ int cmd_read_tree(int argc, const char **argv, const char *cmd_prefix)
if (unpack_trees(nr_trees, t, &opts))
return 128;

if (opts.dir) {
dir_clear(opts.dir);
FREE_AND_NULL(opts.dir);
}

if (opts.debug_unpack || opts.dry_run)
return 0; /* do not write the index out */


Loading…
Cancel
Save