Skip to content

Commit f949703

Browse files
committed
Merge branch 'jk/rebase-apply-leakfix'
Leakfix. * jk/rebase-apply-leakfix: rebase: use child_process_clear() to clean
2 parents f0c570e + 647e870 commit f949703

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

builtin/rebase.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ static int run_am(struct rebase_options *opts)
610610
status = error_errno(_("could not open '%s' for writing"),
611611
rebased_patches);
612612
free(rebased_patches);
613-
strvec_clear(&am.args);
613+
child_process_clear(&am);
614614
return status;
615615
}
616616

@@ -638,7 +638,7 @@ static int run_am(struct rebase_options *opts)
638638
struct reset_head_opts ropts = { 0 };
639639
unlink(rebased_patches);
640640
free(rebased_patches);
641-
strvec_clear(&am.args);
641+
child_process_clear(&am);
642642

643643
ropts.oid = &opts->orig_head->object.oid;
644644
ropts.branch = opts->head_name;
@@ -659,7 +659,7 @@ static int run_am(struct rebase_options *opts)
659659
status = error_errno(_("could not open '%s' for reading"),
660660
rebased_patches);
661661
free(rebased_patches);
662-
strvec_clear(&am.args);
662+
child_process_clear(&am);
663663
return status;
664664
}
665665

t/t3438-rebase-broken-files.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,13 @@ test_expect_success 'unknown key in author-script' '
5858
check_resolve_fails
5959
'
6060

61+
test_expect_success POSIXPERM,SANITY 'unwritable rebased-patches does not leak' '
62+
>.git/rebased-patches &&
63+
chmod a-w .git/rebased-patches &&
64+
65+
git checkout -b side HEAD^ &&
66+
test_commit unrelated &&
67+
test_must_fail git rebase --apply --onto tmp HEAD^
68+
'
69+
6170
test_done

0 commit comments

Comments
 (0)