Skip to content

Commit 5ff6e8a

Browse files
avargitster
authored andcommitted
rebase: don't leak on "--abort"
Fix a leak in the recent 6159e7a (rebase --abort: improve reflog message, 2022-10-12). Before that commit we'd strbuf_release() the reflog message we were formatting, but when that code was refactored to use "ropts.head_msg" the strbuf_release() was omitted. Ideally the three users of "ropts" in cmd_rebase() should use different "ropts" variables, in practice they're completely separate, as this and the other user in the "switch" statement will "goto cleanup", which won't touch "ropts". The third caller after the "switch" is then unreachable if we take these two branches, so all of them are getting a "{ 0 }" init'd "ropts". So it's OK that we're leaving a stale pointer in "ropts.head_msg", cleaning it up was our responsibility, and it won't be used again. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent dd4143e commit 5ff6e8a

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

builtin/rebase.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,6 +1322,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
13221322
if (reset_head(the_repository, &ropts) < 0)
13231323
die(_("could not move back to %s"),
13241324
oid_to_hex(&options.orig_head->object.oid));
1325+
strbuf_release(&head_msg);
13251326
remove_branch_state(the_repository, 0);
13261327
ret = finish_rebase(&options);
13271328
goto cleanup;

t/t7517-per-repo-email.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ test_description='per-repo forced setting of email address'
99
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
1010
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
1111

12+
TEST_PASSES_SANITIZE_LEAK=true
1213
. ./test-lib.sh
1314

1415
test_expect_success 'setup a likely user.useConfigOnly use case' '

0 commit comments

Comments
 (0)