]> git.ipfire.org Git - thirdparty/git.git/commitdiff
mailmap: plug memory leak in read_mailmap_blob()
authorJunio C Hamano <gitster@pobox.com>
Thu, 25 Jul 2024 23:12:41 +0000 (16:12 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 26 Jul 2024 15:00:09 +0000 (08:00 -0700)
When a named object to read mailmap from is not a blob, the code
correctly errors out, but it forgot to free the object data before
doing so.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
mailmap.c
t/t4203-mailmap.sh

index 2d0212f4441d5d1f8e464fbc542d596902953543..2acf97f3076070b35458201b20b8d373ae6cd8d3 100644 (file)
--- a/mailmap.c
+++ b/mailmap.c
@@ -201,8 +201,10 @@ static int read_mailmap_blob(struct string_list *map, const char *name)
        buf = repo_read_object_file(the_repository, &oid, &type, &size);
        if (!buf)
                return error("unable to read mailmap object at %s", name);
-       if (type != OBJ_BLOB)
+       if (type != OBJ_BLOB) {
+               free(buf);
                return error("mailmap is not a blob: %s", name);
+       }
 
        read_mailmap_string(map, buf);
 
index 8a88dd7900ca8a63327bf0853403a38a2c2bc5a9..79e5f42760d9190376442243cebf0273d8cae330 100755 (executable)
@@ -5,6 +5,7 @@ test_description='.mailmap configurations'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 test_expect_success 'setup commits and contacts file' '