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.

Reply via email to