Skip to content

Commit ccdd5d1

Browse files
avargitster
authored andcommitted
mailmap.c: fix a memory leak in free_mailap_{info,entry}()
In the free_mailmap_entry() code added in 0925ce4 (Add map_user() and clear_mailmap() to mailmap, 2009-02-08) the intent was clearly to clear the "me" structure, but while we freed parts of the mailmap_entry structure, we didn't free the structure itself. The same goes for the "mailmap_info" structure. This brings the number of SANITIZE=leak failures in t4203-mailmap.sh down from 50 to 49. Not really progress as far as the number of failures is concerned, but as far as I can tell this fixes all leaks in mailmap.c itself. There's still users of it such as builtin/log.c that call read_mailmap() without a clear_mailmap(), but that's on them. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ebf3c04 commit ccdd5d1

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

mailmap.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ static void free_mailmap_info(void *p, const char *s)
3636
s, debug_str(mi->name), debug_str(mi->email));
3737
free(mi->name);
3838
free(mi->email);
39+
free(mi);
3940
}
4041

4142
static void free_mailmap_entry(void *p, const char *s)
@@ -51,6 +52,7 @@ static void free_mailmap_entry(void *p, const char *s)
5152

5253
me->namemap.strdup_strings = 1;
5354
string_list_clear_func(&me->namemap, free_mailmap_info);
55+
free(me);
5456
}
5557

5658
/*

0 commit comments

Comments
 (0)