git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Kim Gybels <kgybels@infogroep.be>
Cc: git@vger.kernel.org, Eric Sunshine <sunshine@sunshineco.us>,
	Johannes Schindelin <johannes.schindelin@gmx.de>,
	Karsten Blees <blees@dcon.de>, Johannes Sixt <j6t@kdbg.org>
Subject: Re: [PATCH v2] diff: ensure correct lifetime of external_diff_cmd
Date: Fri, 11 Jan 2019 18:44:05 -0800	[thread overview]
Message-ID: <xmqq1s5iy4qy.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20190111202608.10576-1-kgybels@infogroep.be> (Kim Gybels's message of "Fri, 11 Jan 2019 21:26:08 +0100")

Kim Gybels <kgybels@infogroep.be> writes:

> According to getenv(3)'s notes:
>
>     The implementation of getenv() is not required to be reentrant.  The
>     string pointed to by the return value of getenv() may be statically
>     allocated, and can be modified by a subsequent call to getenv(),
>     putenv(3), setenv(3), or unsetenv(3).
> ...
> Signed-off-by: Kim Gybels <kgybels@infogroep.be>
> ---

Thanks, looking good.

Will queue.

>
> Uses xstrdup_or_null as suggested by Eric Sunshine.
>
>  diff.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/diff.c b/diff.c
> index dc9965e836..5634992bbc 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -487,11 +487,11 @@ static const char *external_diff(void)
>  	static const char *external_diff_cmd = NULL;
>  	static int done_preparing = 0;
>  
>  	if (done_preparing)
>  		return external_diff_cmd;
> -	external_diff_cmd = getenv("GIT_EXTERNAL_DIFF");
> +	external_diff_cmd = xstrdup_or_null(getenv("GIT_EXTERNAL_DIFF"));
>  	if (!external_diff_cmd)
>  		external_diff_cmd = external_diff_cmd_cfg;
>  	done_preparing = 1;
>  	return external_diff_cmd;
>  }

      reply	other threads:[~2019-01-12  2:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-09 22:10 [PATCH] diff: ensure correct lifetime of external_diff_cmd Kim Gybels
2019-01-09 23:10 ` Eric Sunshine
2019-01-10 15:47   ` Johannes Schindelin
2019-01-10 18:27   ` Junio C Hamano
2019-01-11 20:26 ` [PATCH v2] " Kim Gybels
2019-01-12  2:44   ` Junio C Hamano [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq1s5iy4qy.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=blees@dcon.de \
    --cc=git@vger.kernel.org \
    --cc=j6t@kdbg.org \
    --cc=johannes.schindelin@gmx.de \
    --cc=kgybels@infogroep.be \
    --cc=sunshine@sunshineco.us \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).