Re: [PATCH v7 1/4] help: use list_aliases() for alias listing
From: Junio C Hamano <hidden>
Date: 2026-02-24 22:42:00
Jacob Keller [off-list ref] writes:
quoted hunk
SUMMARY: AddressSanitizer: 1453 byte(s) leaked in 37 allocation(s). This leak occurs because you now copy and store the value of the alias in the util element, but the call of list_aliases() in list_cmd() doesn't clean these up, since its string_list_clear passes 0 to the free_util argument. The following fixed it for me:diff --git c/git.c i/git.c index 744cb6527e06..aeb099ab1162 100644 --- c/git.c +++ i/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; }
Thanks. This looks like one of the right things to do. I checked all list_*() that are called from the loop in this list_cmds(), and list_aliases() is the only thing that uses .util member of the string_list_item instances. However, we need to be a bit careful with list_cmds_by_config(). It sorts the list accumulated so far, uses remove_duplicates() on it without passing free_util=1, so there is also the same kind of leak there, I suspect, until we adjust the call there.