Message ID | 20231007172031.GA1524950@coredump.intra.peff.net (mailing list archive) |
---|---|
State | Accepted |
Commit | c1b754d0597be83439ecc8de2a59a90f35cd4040 |
Headers | show |
Series | repack: free existing_cruft array after use | expand |
On Sat, Oct 07, 2023 at 01:20:31PM -0400, Jeff King wrote: > On Mon, Oct 02, 2023 at 08:44:32PM -0400, Taylor Blau wrote: > > > +static void collapse_small_cruft_packs(FILE *in, size_t max_size, > > + struct existing_packs *existing) > > +{ > > + struct packed_git **existing_cruft, *p; > > + struct strbuf buf = STRBUF_INIT; > > [...] > > + > > + strbuf_release(&buf); > > +} > > Coverity (using the just-merged-to-next version of the workflow file!) > flagged a leak here. Since the topic (tb/repack-max-cruft-size) is in > 'next', I think we'd want this on top: Woohoo! I'm glad that this is already paying dividends. > -- >8 -- > Subject: [PATCH] repack: free existing_cruft array after use > > We allocate an array of packed_git pointers so that we can sort the list > of cruft packs, but we never free the array, causing a small leak. Note > that we don't need to free the packed_git structs themselves; they're > owned by the repository object. Thanks, I can't believe I missed this when writing this function. The fix looks obviously correct to me, so this has my: Acked-by: Taylor Blau <me@ttaylorr.com> Thanks, Taylor
Taylor Blau <me@ttaylorr.com> writes: > On Sat, Oct 07, 2023 at 01:20:31PM -0400, Jeff King wrote: >> On Mon, Oct 02, 2023 at 08:44:32PM -0400, Taylor Blau wrote: >> ... >> Coverity (using the just-merged-to-next version of the workflow file!) >> flagged a leak here. Since the topic (tb/repack-max-cruft-size) is in >> 'next', I think we'd want this on top: > > Woohoo! I'm glad that this is already paying dividends. > ... > Thanks, I can't believe I missed this when writing this function. The > fix looks obviously correct to me, so this has my: > > Acked-by: Taylor Blau <me@ttaylorr.com> > > Thanks, Will queue. Thanks.
diff --git a/builtin/repack.c b/builtin/repack.c index a1a893d952..69e8f302c0 100644 --- a/builtin/repack.c +++ b/builtin/repack.c @@ -955,6 +955,7 @@ static void collapse_small_cruft_packs(FILE *in, size_t max_size, existing->non_kept_packs.items[i].string); strbuf_release(&buf); + free(existing_cruft); } static int write_cruft_pack(const struct pack_objects_args *args,