Skip to content

Commit 423ff9b

Browse files
peffgitster
authored andcommitted
config: make a copy of $GIT_CONFIG string
cmd_config() points our source filename pointer at the return value of getenv(), but that value may be invalidated by further calls to environment functions. Let's copy it to make sure it remains valid. We don't need to bother freeing it, as it remains part of the whole-process global state until we exit. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 406bab3 commit 423ff9b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

builtin/config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
595595
int nongit = !startup_info->have_repository;
596596
char *value;
597597

598-
given_config_source.file = getenv(CONFIG_ENVIRONMENT);
598+
given_config_source.file = xstrdup_or_null(getenv(CONFIG_ENVIRONMENT));
599599

600600
argc = parse_options(argc, argv, prefix, builtin_config_options,
601601
builtin_config_usage,

0 commit comments

Comments
 (0)