diff mbox series

[v2,19/22] builtin/fmt-merge-msg: fix leaking buffers

Message ID 84b68affa0d8420ee907a6bb1af15c7f37b13485.1725530720.git.ps@pks.im (mailing list archive)
State Accepted
Commit 68bd0a94bedf520bc67ca38216e839770f291296
Headers show
Series Memory leak fixes (pt.6) | expand

Commit Message

Patrick Steinhardt Sept. 5, 2024, 10:09 a.m. UTC
Fix leaking input and output buffers in git-fmt-merge-msg(1).

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 builtin/fmt-merge-msg.c  | 2 ++
 t/t6200-fmt-merge-msg.sh | 1 +
 2 files changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c
index 957786d1b3a..0b162f8fab1 100644
--- a/builtin/fmt-merge-msg.c
+++ b/builtin/fmt-merge-msg.c
@@ -67,6 +67,8 @@  int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
 		return ret;
 	write_in_full(STDOUT_FILENO, output.buf, output.len);
 
+	strbuf_release(&input);
+	strbuf_release(&output);
 	free(inpath);
 	return 0;
 }
diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh
index 5a221f8ef1f..ac57b0e4ae3 100755
--- a/t/t6200-fmt-merge-msg.sh
+++ b/t/t6200-fmt-merge-msg.sh
@@ -8,6 +8,7 @@  test_description='fmt-merge-msg test'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 . "$TEST_DIRECTORY/lib-gpg.sh"