Thread (75 messages) flat view 75 messages, 8 authors, 2021-12-13
STALE1742d

[PATCH v3 02/11] checkout, read-tree: fix leak of unpack_trees_options.dir

From: Elijah Newren via GitGitGadget <hidden>
Date: 2021-09-27 16:34:07
Subsystem: the rest · Maintainer: Linus Torvalds

From: Elijah Newren <redacted>

Signed-off-by: Elijah Newren <redacted>
---
 builtin/checkout.c  | 4 ++++
 builtin/read-tree.c | 5 +++++
 2 files changed, 9 insertions(+)
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 8c69dcdf72a..5335435d616 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -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) {
 			/*
diff --git a/builtin/read-tree.c b/builtin/read-tree.c
index 485e7b04794..96102c222bf 100644
--- a/builtin/read-tree.c
+++ b/builtin/read-tree.c
@@ -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 */
 
-- 
gitgitgadget
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help