Skip to content

Commit c512d27

Browse files
newrengitster
authored andcommitted
checkout, read-tree: fix leak of unpack_trees_options.dir
Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 446cc55 commit c512d27

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

builtin/checkout.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,10 @@ static int merge_working_tree(const struct checkout_opts *opts,
760760
init_tree_desc(&trees[1], tree->buffer, tree->size);
761761

762762
ret = unpack_trees(2, trees, &topts);
763+
if (topts.dir) {
764+
dir_clear(topts.dir);
765+
FREE_AND_NULL(topts.dir);
766+
}
763767
clear_unpack_trees_porcelain(&topts);
764768
if (ret == -1) {
765769
/*

builtin/read-tree.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,11 @@ int cmd_read_tree(int argc, const char **argv, const char *cmd_prefix)
250250
if (unpack_trees(nr_trees, t, &opts))
251251
return 128;
252252

253+
if (opts.dir) {
254+
dir_clear(opts.dir);
255+
FREE_AND_NULL(opts.dir);
256+
}
257+
253258
if (opts.debug_unpack || opts.dry_run)
254259
return 0; /* do not write the index out */
255260

0 commit comments

Comments
 (0)