git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Stefan Beller <sbeller@google.com>
Date
Apr 25, 2017, 15:52 UTC
Message-ID
<CAGZ79kb9hsvrzc=RnhhyJf-tTnr9rTfV-TQWimYFGwU_Kuew9w@mail.gmail.com>
In-Reply-To
<20170425005746.tulvexabonlexah3@sigill.intra.peff.net>
On Mon, Apr 24, 2017 at 5:57 PM, Jeff King <peff@peff.net> wrote:
Show 15 quoted lines
> 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@peff.net>
> ---

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

Previous: Jeff King
Message 2 of 2 in “submodule_init: die cleanly on submodules without url defined”
  1. submodule_init: die cleanly on submodules without url definedJeff King, Apr 25, 2017
  2. Stefan BellerApr 25, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.