Re: [PATCH] fmt-merge-msg: avoid leaking strbuf in shortlog()
- From
Jeff King <peff@peff.net>
- Date
- Dec 7, 2017, 21:27 UTC
- Message-ID
- <20171207212735.GD12850@sigill.intra.peff.net>
- In-Reply-To
- <b2238da3-9eba-1521-f4ca-3b805f103555@web.de>
On Thu, Dec 07, 2017 at 09:22:49PM +0100, René Scharfe wrote:
> Use string_list_append_nodup() instead of string_list_append() to hand > over ownership of a detached strbuf and thus avoid leaking its memory.
Looks obviously correct (though one thing missing from the diff context is whether "subjects" is set to DUP -- it is, which is good).
Grepping for "list_append.*detach" shows a few other possible cases in transport-helper.c, which I think are leaks.
I wondered if it would be possible to write a coccinelle rule for this, but I think it's not possible. Whether this is right depends on the strdup_strings flag, which could change at runtime (though in practice it doesn't).
-Peff