]> git.ipfire.org Git - thirdparty/git.git/commitdiff
format-patch: free rev.message_id when exiting
authorJeff King <peff@peff.net>
Fri, 19 May 2023 00:03:25 +0000 (20:03 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 19 May 2023 01:33:04 +0000 (18:33 -0700)
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
3ece9bf0f9 (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
20bd08aefb (t9001: mark the script as no longer leak checker clean,
2023-05-17).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/log.c
t/t9001-send-email.sh

index 7d195789633978c03c18e2c331d75f1b56f924e8..ab747603862c2c0bbb5a24c8b466e4722b453eaa 100644 (file)
@@ -2415,6 +2415,7 @@ done:
        strbuf_release(&rdiff_title);
        strbuf_release(&sprefix);
        free(to_free);
+       free(rev.message_id);
        if (rev.ref_message_ids)
                string_list_clear(rev.ref_message_ids, 0);
        free(rev.ref_message_ids);
index 20511032263ae171e3450e01578e26db3f6fdee0..8d49eff91a384e0df883e242ffdfd0edac6c3c60 100755 (executable)
@@ -4,7 +4,7 @@ test_description='git send-email'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
-# no longer TEST_PASSES_SANITIZE_LEAK=true - format-patch --thread leaks
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 # May be altered later in the test