From: Jeff King Date: Sun, 28 Jun 2026 09:06:19 GMT Subject: Re: [PATCH] reftable: fix unlikely leak on API error Message-ID: <20260628090619.GA699336@coredump.intra.peff.net> In-Reply-To: <20260628090314.GA661068@coredump.intra.peff.net> On Sun, Jun 28, 2026 at 05:03:14AM -0400, Jeff King wrote: > Noticed by Coverity as a "new" problem, though it has been there for > over a year. Presumably the nearby changes from 44f46f2be5 (reftable: > split up write options, 2026-06-25) confused it. There's a backlog of > hundreds of Coverity problems, most of which are garbage, so I tend to > only look at the ones it marks as new. This does conflict textually with 44f46f2be5, which adds a new line nearby. Resolving like: diff --cc reftable/writer.c index f850e9d599,1bd4aa388b..d969a6a021 --- a/reftable/writer.c +++ b/reftable/writer.c @@@ -161,9 -158,10 +157,13 @@@ int reftable_writer_new(struct reftable if (opts.block_size >= (1 << 24)) return REFTABLE_API_ERROR; + if (!hash_id) + hash_id = REFTABLE_HASH_SHA1; + + wp = reftable_calloc(1, sizeof(*wp)); + if (!wp) + return REFTABLE_OUT_OF_MEMORY_ERROR; + reftable_buf_init(&wp->block_writer_data.last_key); reftable_buf_init(&wp->last_key); reftable_buf_init(&wp->scratch); makes sense to me, as it keeps the hash_id setting with the "opts" setup. -Peff