git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "René Scharfe" <l.s.r@web.de>
To: Git List <git@vger.kernel.org>
Subject: [PATCH] column: release strbuf and string_list after use
Date: Sun, 26 Nov 2023 12:57:36 +0100	[thread overview]
Message-ID: <f087137d-a5aa-487e-a1cb-0ad7117b38ed@web.de> (raw)

Releasing strbuf and string_list just before exiting is not strictly
necessary, but it gets rid of false positives reported by leak checkers,
which can then be more easily used to show that the column-printing
machinery behind print_columns() are free of leaks.

Signed-off-by: René Scharfe <l.s.r@web.de>
---
 builtin/column.c  | 2 ++
 t/t9002-column.sh | 1 +
 2 files changed, 3 insertions(+)

diff --git a/builtin/column.c b/builtin/column.c
index a83be8bc99..e80218f81f 100644
--- a/builtin/column.c
+++ b/builtin/column.c
@@ -56,5 +56,7 @@ int cmd_column(int argc, const char **argv, const char *prefix)
 		string_list_append(&list, sb.buf);

 	print_columns(&list, colopts, &copts);
+	strbuf_release(&sb);
+	string_list_clear(&list, 0);
 	return 0;
 }
diff --git a/t/t9002-column.sh b/t/t9002-column.sh
index 6d3dbde3fe..348cc40658 100755
--- a/t/t9002-column.sh
+++ b/t/t9002-column.sh
@@ -1,6 +1,7 @@
 #!/bin/sh

 test_description='git column'
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh

 test_expect_success 'setup' '
--
2.43.0

             reply	other threads:[~2023-11-26 11:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-26 11:57 René Scharfe [this message]
2023-11-27 12:04 ` [PATCH] column: release strbuf and string_list after use Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f087137d-a5aa-487e-a1cb-0ad7117b38ed@web.de \
    --to=l.s.r@web.de \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).