Skip to content

Commit 6e65854

Browse files
avargitster
authored andcommitted
sequencer: fix a memory leak in do_reset()
Fix a memory leak introduced in 9055e40 (sequencer: introduce new commands to reset the revision, 2018-04-25), which called setup_unpack_trees_porcelain() without a corresponding call to clear_unpack_trees_porcelain(). This introduces a change in behavior in that we now start calling clear_unpack_trees_porcelain() even without having called the setup_unpack_trees_porcelain(). That's OK, that clear function, like most others, will accept a zero'd out struct. This inches us closer to passing various tests in "t34*.sh" (e.g. "t3434-rebase-i18n.sh"), but because they have so many other memory leaks in revisions.c this doesn't make any test file or even a single test pass. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0c52cf8 commit 6e65854

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sequencer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3646,7 +3646,7 @@ static int do_reset(struct repository *r,
36463646
struct lock_file lock = LOCK_INIT;
36473647
struct tree_desc desc = { 0 };
36483648
struct tree *tree;
3649-
struct unpack_trees_options unpack_tree_opts;
3649+
struct unpack_trees_options unpack_tree_opts = { 0 };
36503650
int ret = 0;
36513651

36523652
if (repo_hold_locked_index(r, &lock, LOCK_REPORT_ON_ERROR) < 0)
@@ -3683,7 +3683,6 @@ static int do_reset(struct repository *r,
36833683
}
36843684
}
36853685

3686-
memset(&unpack_tree_opts, 0, sizeof(unpack_tree_opts));
36873686
setup_unpack_trees_porcelain(&unpack_tree_opts, "reset");
36883687
unpack_tree_opts.head_idx = 1;
36893688
unpack_tree_opts.src_index = r->index;
@@ -3723,6 +3722,7 @@ static int do_reset(struct repository *r,
37233722
if (ret < 0)
37243723
rollback_lock_file(&lock);
37253724
strbuf_release(&ref_name);
3725+
clear_unpack_trees_porcelain(&unpack_tree_opts);
37263726
return ret;
37273727
}
37283728

0 commit comments

Comments
 (0)