Re: [PATCH] diff: ensure correct lifetime of external_diff_cmd

2019-01-10 Thread Junio C Hamano
Eric Sunshine writes: > However, you might also consider using xstrdup_or_null(), like this: > > external_diff_cmd = xstrdup_or_null(getenv(...)); > if (!external_diff_cmd) > ...as before... > >> done_preparing = 1; >> return external_diff_cmd; >> } Looks good.

Re: [PATCH] diff: ensure correct lifetime of external_diff_cmd

2019-01-10 Thread Johannes Schindelin
Hi, On Wed, 9 Jan 2019, Eric Sunshine wrote: > On Wed, Jan 9, 2019 at 5:19 PM Kim Gybels wrote: > > According to getenv(3)'s notes: > > [...] > > Since strings returned by getenv() are allowed to change on subsequent > > calls to getenv(), make sure to duplicate when caching external_diff_cmd >

Re: [PATCH] diff: ensure correct lifetime of external_diff_cmd

2019-01-09 Thread Eric Sunshine
On Wed, Jan 9, 2019 at 5:19 PM Kim Gybels wrote: > According to getenv(3)'s notes: > [...] > Since strings returned by getenv() are allowed to change on subsequent > calls to getenv(), make sure to duplicate when caching external_diff_cmd > from environment. > [...] > Signed-off-by: Kim Gybels >

[PATCH] diff: ensure correct lifetime of external_diff_cmd

2019-01-09 Thread Kim Gybels
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). Since str