Skip to content

Commit cfa1209

Browse files
peffgitster
authored andcommitted
format-patch: free rev.message_id when exiting
We may allocate a message-id string via gen_message_id(), but we never free it, causing a small leak. This can be demonstrated by running t9001 with a leak-checking build. The offending test is the one touched by 3ece9bf (send-email: clear the $message_id after validation, 2023-05-17), but the leak is much older than that. The test was simply unlucky enough to trigger the leaking code path for the first time. We can fix this by freeing the string at the end of the function. We can also re-mark the test script as leak-free, effectively reverting 20bd08a (t9001: mark the script as no longer leak checker clean, 2023-05-17). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 20bd08a commit cfa1209

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

builtin/log.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2415,6 +2415,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
24152415
strbuf_release(&rdiff_title);
24162416
strbuf_release(&sprefix);
24172417
free(to_free);
2418+
free(rev.message_id);
24182419
if (rev.ref_message_ids)
24192420
string_list_clear(rev.ref_message_ids, 0);
24202421
free(rev.ref_message_ids);

t/t9001-send-email.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ test_description='git send-email'
44
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
55
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
66

7-
# no longer TEST_PASSES_SANITIZE_LEAK=true - format-patch --thread leaks
7+
TEST_PASSES_SANITIZE_LEAK=true
88
. ./test-lib.sh
99

1010
# May be altered later in the test

0 commit comments

Comments
 (0)