summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2022-04-13 20:01:30 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-04-14 06:56:08 (GMT)
commitb925fcf12951dba85313afd08c6154d8d978b03e (patch)
treeab6f8233f28de19308c6cf501376230417df54de /t
parent1e2574e5854e989f17d44f505f73278455b28eeb (diff)
downloadgit-b925fcf12951dba85313afd08c6154d8d978b03e.zip
git-b925fcf12951dba85313afd08c6154d8d978b03e.tar.gz
git-b925fcf12951dba85313afd08c6154d8d978b03e.tar.bz2
t/helper/test-fast-rebase.c: don't leak "struct strbuf"
Fix a memory leak that's been with us since f9500261e0a (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 f9500261e0a 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>
Diffstat (limited to 't')
-rw-r--r--t/helper/test-fast-rebase.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/t/helper/test-fast-rebase.c b/t/helper/test-fast-rebase.c
index fc2d460..993b90e 100644
--- a/t/helper/test-fast-rebase.c
+++ b/t/helper/test-fast-rebase.c
@@ -201,8 +201,6 @@ int cmd__fast_rebase(int argc, const char **argv)
}
if (create_symref("HEAD", branch_name.buf, reflog_msg.buf) < 0)
die(_("unable to update HEAD"));
- strbuf_release(&reflog_msg);
- strbuf_release(&branch_name);
prime_cache_tree(the_repository, the_repository->index,
result.tree);
@@ -221,5 +219,8 @@ int cmd__fast_rebase(int argc, const char **argv)
if (write_locked_index(&the_index, &lock,
COMMIT_LOCK | SKIP_IF_UNCHANGED))
die(_("unable to write %s"), get_index_file());
+
+ strbuf_release(&reflog_msg);
+ strbuf_release(&branch_name);
return (result.clean == 0);
}