From: Jeff King Date: Thu, 16 Feb 2012 08:03:52 +0000 (-0500) Subject: config: copy the return value of prefix_filename X-Git-Tag: v1.7.10-rc0~52^2~6 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=839de2527258879aa21ae7ad425353f06dbb4717;p=git.git config: copy the return value of prefix_filename The prefix_filename function returns a pointer to a static buffer which may be overwritten by subsequent calls. Since we are going to keep the result around for a while, let's be sure to duplicate it for safety. I don't think this can be triggered as a bug in the current code, but it's a good idea to be defensive, as any resulting bug would be quite subtle. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- diff --git a/builtin/config.c b/builtin/config.c index d35c06ae5..55854bef6 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -377,9 +377,10 @@ int cmd_config(int argc, const char **argv, const char *prefix) config_exclusive_filename = git_pathdup("config"); else if (given_config_file) { if (!is_absolute_path(given_config_file) && prefix) - config_exclusive_filename = prefix_filename(prefix, - strlen(prefix), - given_config_file); + config_exclusive_filename = + xstrdup(prefix_filename(prefix, + strlen(prefix), + given_config_file)); else config_exclusive_filename = given_config_file; }