mailmap: plug memory leak in read_mailmap_blob()

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>
This commit is contained in:
Junio C Hamano
2024-07-25 16:12:41 -07:00
parent ad57f148c6
commit d98d9c77e5
2 changed files with 4 additions and 1 deletions

View File

@ -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);