Skip to content

Commit 82ea7e5

Browse files
pks-tgitster
authored andcommitted
pretty: fix leaking key/value separator buffer
The `format_set_trailers_options()` function is responsible for parsing a custom pretty format for trailers. It puts the parsed options into a `struct process_trailer_options` structure, while the allocated memory required for this will be put into separate caller-provided arguments. It is thus the caller's responsibility to free the memory not via the options structure, but via the other parameters. While we do this alright for the separator and filter keys, we do not free the memory associated with the key/value separator. Fix this to plug this memory leak. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 60289b5 commit 82ea7e5

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

pretty.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1776,6 +1776,7 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
17761776
}
17771777
trailer_out:
17781778
string_list_clear(&filter_list, 0);
1779+
strbuf_release(&kvsepbuf);
17791780
strbuf_release(&sepbuf);
17801781
return ret;
17811782
}

t/t4205-log-pretty-formats.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#
66

77
test_description='Test pretty formats'
8+
9+
TEST_PASSES_SANITIZE_LEAK=true
810
. ./test-lib.sh
911

1012
# Tested non-UTF-8 encoding

0 commit comments

Comments
 (0)