Re: [PATCH 2/8] builtin/multi-pack-index.c: support --stdin-packs mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Sep 10 2021, Taylor Blau wrote:

> +	struct strbuf buf = STRBUF_INIT;
> +	while (strbuf_getline(&buf, stdin) != EOF) {
> +		string_list_append(to, strbuf_detach(&buf, NULL));

If you strbuf_detach() it...


> +		struct string_list packs = STRING_LIST_INIT_NODUP;

...init the list with NODUP...

> +		string_list_clear(&packs, 0);

...and call string_list_clear() you'll leak memory, since the
string_list will think that someone else is taking care of this memory.

I had some recent musings about how this API is bad, and I've got local
WIP patches to fix it, but in the meantime you need to:

    packs.strdup_strings = 1;

Before calling string_list_clear(). I.e. we didn't strdup(), but during
free() we pretend that we did, because we did, just not in
string_list_append().



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux