Re: [PATCH] submodule_init: die cleanly on submodules without url defined

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

 



On Mon, Apr 24, 2017 at 5:57 PM, Jeff King <peff@xxxxxxxx> wrote:
> When we init a submodule, we try to die when it has no URL
> defined:
>
>   url = xstrdup(sub->url);
>   if (!url)
>           die(...);
>
> But that's clearly nonsense. xstrdup() will never return
> NULL, and if sub->url is NULL, we'll segfault.
>
> These two bits of code need to be flipped, so we check
> sub->url before looking at it.
>
> Signed-off-by: Jeff King <peff@xxxxxxxx>
> ---

Makes sense. At the time I assumed xstrdup had a _or_null
behavior (i.e. if NULL goes in, it is not duplicated, but rather
return NULL)

Thanks,
Stefan



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