Re: [PATCHv13 5/7] git submodule update: have a dedicated helper for cloning

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

 



On Fri, Feb 19, 2016 at 11:08 AM, Jeff King <peff@xxxxxxxx> wrote:
> On Fri, Feb 19, 2016 at 12:20:48PM -0500, Eric Sunshine wrote:
>
>> >>> +             argv_array_pushl(&cp->args, "--path", sub->path, NULL);
>> >>> +             argv_array_pushl(&cp->args, "--name", sub->name, NULL);
>> >>> +             argv_array_pushl(&cp->args, "--url", strdup(url), NULL);
>> >>
>> >> No need to strdup() here; argv_array handles its own memory, so this
>> >> just leaks (and if we were keeping it, it should be xstrdup(), of
>> >> course).
>> >
>> > We cannot remove the strdup as the url is a local variable we read in from
>> > git_config_get_string and the local variable is going out of scope before the
>> > child process ends?
>> >
>> > I'll change it to xstrdup then.
>>
>> When Peff said "argv_array handles its own memory", he meant that it
>> does xstrdup() itself, so there's no need for you to do so a second
>> time manually (leaking a string as a consequence).
>
> Exactly. :) Sorry for not being clear the first time around.

Sorry for being confused to easily. I should have just read the code of
argv_array_pushl before answering. In the resend I removed the strdup.

Thanks,
Stefan

>
> -Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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]