mirror of
https://github.com/git/git.git
synced 2026-03-04 14:37:35 +01:00
git, help: fix memory leaks in alias listing
The list_aliases() function sets the util pointer of each list item to a heap-allocated copy of the alias command value. Two callers failed to free these util pointers: - list_cmds() in git.c collects a string list with STRING_LIST_INIT_DUP and clears it with string_list_clear(&list, 0), which frees the duplicated strings (strdup_strings=1) but not the util pointers. Pass free_util=1 to free them. - list_cmds_by_config() in help.c calls string_list_sort_u(list, 0) to deduplicate the list before processing completion.commands overrides. When duplicate entries are removed, the util pointer of each discarded item is leaked because free_util=0. Pass free_util=1 to free them. Reported-by: Jacob Keller <jacob.e.keller@intel.com> Signed-off-by: Jonatan Holmgren <jonatan@jontes.page> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
6589294375
commit
cdef625509
2
git.c
2
git.c
@@ -119,7 +119,7 @@ static int list_cmds(const char *spec)
|
||||
}
|
||||
for (size_t i = 0; i < list.nr; i++)
|
||||
puts(list.items[i].string);
|
||||
string_list_clear(&list, 0);
|
||||
string_list_clear(&list, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user