* [PATCH] mailmap: plug memory leak in read_mailmap_blob()
@ 2024-07-25 23:12 Junio C Hamano
2024-07-26 4:44 ` Jeff King
0 siblings, 1 reply; 2+ messages in thread
From: Junio C Hamano @ 2024-07-25 23:12 UTC (permalink / raw)
To: git
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 | 4 +++-
t/t4203-mailmap.sh | 1 +
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/mailmap.c b/mailmap.c
index 2d0212f444..2acf97f307 100644
--- 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);
diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh
index 8a88dd7900..79e5f42760 100755
--- a/t/t4203-mailmap.sh
+++ b/t/t4203-mailmap.sh
@@ -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' '
--
2.46.0-rc2-67-g99767055c1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mailmap: plug memory leak in read_mailmap_blob()
2024-07-25 23:12 [PATCH] mailmap: plug memory leak in read_mailmap_blob() Junio C Hamano
@ 2024-07-26 4:44 ` Jeff King
0 siblings, 0 replies; 2+ messages in thread
From: Jeff King @ 2024-07-26 4:44 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
On Thu, Jul 25, 2024 at 04:12:41PM -0700, Junio C Hamano wrote:
> 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.
> [..]
> - if (type != OBJ_BLOB)
> + if (type != OBJ_BLOB) {
> + free(buf);
> return error("mailmap is not a blob: %s", name);
> + }
Looks obviously correct. This one is almost certainly my fault.
-Peff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-07-26 4:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-25 23:12 [PATCH] mailmap: plug memory leak in read_mailmap_blob() Junio C Hamano
2024-07-26 4:44 ` Jeff King
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).