From: Jeff King Date: Fri, 12 Jan 2018 13:11:02 GMT Subject: Re: [PATCH v3 1/4] trace.c: introduce trace_run_command() Message-ID: <20180112131101.GA7880@sigill.intra.peff.net> In-Reply-To: <20180112130522.GB27499@sigill.intra.peff.net> On Fri, Jan 12, 2018 at 08:05:22AM -0500, Jeff King wrote: > > +void trace_run_command(const struct child_process *cp) > > +{ > > + struct strbuf buf = STRBUF_INIT; > > + > > + if (!prepare_trace_line(__FILE__, __LINE__, > > + &trace_default_key, &buf)) > > + return; > > + > > + strbuf_addf(&buf, "trace: run_command:"); > > + > > + sq_quote_argv(&buf, cp->argv, 0); > > + print_trace_line(&trace_default_key, &buf); > > +} > > It looks like this leaks "buf". > > If prepare_trace_line() returns 0, I think it's safe to assume that > nothing was allocated. So we'd just need a strbuf_release() at the end. > > Looking at the other trace functions, it looks like a bunch of them have > the same problem. Never mind, I got fooled by print_trace_line(), which does quite a bit more than its name says. :) This call (and the existing ones) are all fine.