mirror of
https://github.com/git/git.git
synced 2024-11-15 14:53:12 +01:00
get_super_prefix(): copy getenv() result
The return value of getenv() is not guaranteed to remain valid across multiple calls (nor across calls to setenv()). Since this function caches the result for the length of the program, we must make a copy to ensure that it is still valid when we need it. Reported-by: Yngve N. Pettersen <yngve@vivaldi.com> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
98cdfbb84a
commit
8aac69038f
@ -107,7 +107,7 @@ char *git_work_tree_cfg;
|
||||
|
||||
static char *git_namespace;
|
||||
|
||||
static const char *super_prefix;
|
||||
static char *super_prefix;
|
||||
|
||||
/*
|
||||
* Repository-local GIT_* environment variables; see cache.h for details.
|
||||
@ -240,7 +240,7 @@ const char *get_super_prefix(void)
|
||||
{
|
||||
static int initialized;
|
||||
if (!initialized) {
|
||||
super_prefix = getenv(GIT_SUPER_PREFIX_ENVIRONMENT);
|
||||
super_prefix = xstrdup_or_null(getenv(GIT_SUPER_PREFIX_ENVIRONMENT));
|
||||
initialized = 1;
|
||||
}
|
||||
return super_prefix;
|
||||
|
Loading…
Reference in New Issue
Block a user