Re: [PATCH v4 1/4] rebase: start implementing it as a builtin

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jul 9, 2018 at 3:59 AM Andrei Rybak <rybak.a.v@xxxxxxxxx> wrote:
> On 2018-07-08 20:01, Pratik Karki wrote:
> > +static int use_builtin_rebase(void)
> > +{
> > +     struct child_process cp = CHILD_PROCESS_INIT;
> > +     struct strbuf out = STRBUF_INIT;
> > +     int ret;
> > +
> > +     argv_array_pushl(&cp.args,
> > +                      "config", "--bool", "rebase.usebuiltin", NULL);
> > +     cp.git_cmd = 1;
> > +     if (capture_command(&cp, &out, 6))
> > +             return 0;
>
> Does strbuf out leak on return here?

Good catch. This _is_ a potential leak. Here is an excerpt from the
documentation of pipe_command(), which is called by capture_command():

    Any output collected in the buffers is kept even if the
    command returns a non-zero exit.

So, yes, this needs a strbuf_release() before returning.

> > +     strbuf_trim(&out);
> > +     ret = !strcmp("true", out.buf);
> > +     strbuf_release(&out);
> > +     return ret;
> > +}



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux