Re: [PATCH v7 1/4] help: use list_aliases() for alias listing
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 24, 2026, 22:41 UTC
- Message-ID
- <xmqq1pi9epc9.fsf@gitster.g>
- In-Reply-To
- <6953f6f2-22e8-4efb-8169-395e1c52634f@intel.com>
Jacob Keller <jacob.e.keller@intel.com> writes:
Show 21 quoted lines
> 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.