]> Kevux Git Server - rit/commitdiff
column: release strbuf and string_list after use
authorRené Scharfe <l.s.r@web.de>
Sun, 26 Nov 2023 11:57:36 +0000 (12:57 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Nov 2023 00:59:56 +0000 (09:59 +0900)
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/column.c
t/t9002-column.sh

index 158fdf5..798161b 100644 (file)
@@ -55,5 +55,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;
 }
index 6d3dbde..348cc40 100755 (executable)
@@ -1,6 +1,7 @@
 #!/bin/sh
 
 test_description='git column'
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 test_expect_success 'setup' '