Skip to content

Commit 78fbea3

Browse files
avargitster
authored andcommitted
t/helper/test-fast-rebase.c: don't leak "struct strbuf"
Fix a memory leak that's been with us since f950026 (fast-rebase: write conflict state to working tree, index, and HEAD, 2021-05-20) changed this code to move these strbuf_release() into an if/else block. We'll also add to "reflog_msg" in the "else" arm of the "if" block being modified here, and we'll append to "branch_msg" in both cases. But after f950026 only the "if" block would free these two "struct strbuf". Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 1e2574e commit 78fbea3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

t/helper/test-fast-rebase.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,6 @@ int cmd__fast_rebase(int argc, const char **argv)
201201
}
202202
if (create_symref("HEAD", branch_name.buf, reflog_msg.buf) < 0)
203203
die(_("unable to update HEAD"));
204-
strbuf_release(&reflog_msg);
205-
strbuf_release(&branch_name);
206204

207205
prime_cache_tree(the_repository, the_repository->index,
208206
result.tree);
@@ -221,5 +219,8 @@ int cmd__fast_rebase(int argc, const char **argv)
221219
if (write_locked_index(&the_index, &lock,
222220
COMMIT_LOCK | SKIP_IF_UNCHANGED))
223221
die(_("unable to write %s"), get_index_file());
222+
223+
strbuf_release(&reflog_msg);
224+
strbuf_release(&branch_name);
224225
return (result.clean == 0);
225226
}

0 commit comments

Comments
 (0)