Re: [PATCH] fmt-merge-msg: avoid leaking strbuf in shortlog()
- From
Jeff King <peff@peff.net>
- Date
- Dec 8, 2017, 21:11 UTC
- Message-ID
- <20171208211137.GA7355@sigill.intra.peff.net>
- In-Reply-To
- <e1daa2b6-004b-ad66-b84d-84fa70a44baf@web.de>
On Fri, Dec 08, 2017 at 06:29:31PM +0100, René Scharfe wrote:
Show 10 quoted lines
> Am 07.12.2017 um 22:27 schrieb Jeff King: > > Grepping for "list_append.*detach" shows a few other possible cases in > > transport-helper.c, which I think are leaks. > > -- >8 -- > Subject: [PATCH] transport-helper: plug strbuf and string_list leaks > > Transfer ownership of detached strbufs to string_lists of the > duplicating variety by calling string_list_append_nodup() instead of > string_list_append() to avoid duplicating and then leaking the buffer.
Thanks, this part looks obviously correct.
> While at it make sure to release the string_list when done; > push_refs_with_export() already does that.
This one takes a bit more digging. I've been bitten before in Git's code by freeing what appeared to be a leak only to find out that we had passed the pointers off to some other data structure which expected them to persist.
Here we feed them to set_helper_option(), which passes them to quote_c_style(), which makes a copy into a strbuf. So I think all is well.
-Peff