From: Ævar Arnfjörð Bjarmason Date: Sat, 11 Sep 2021 10:05:05 GMT Subject: Re: [PATCH 2/8] builtin/multi-pack-index.c: support --stdin-packs mode Message-ID: <87ee9va0ie.fsf@evledraar.gmail.com> In-Reply-To: <2a16f11790b79ab452233b6f28acac607c0abd28.1631331139.git.me@ttaylorr.com> 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().