From fa42dcae0c53876f51cb820f2b668b4ad3821178 Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Fri, 22 Apr 2016 14:12:07 +0200 Subject: [PATCH] get_windows_home_directory might point to wrong buffer If %HOME% is set and build_libgit_environment() is called, the static buffer might point to an invalid buffer. Regression of commit 25fc2b0b93032863356ba7b90b776fdb3bcef07b. Signed-off-by: Sven Strickroth --- ext/gitdll/gitdll.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ext/gitdll/gitdll.c b/ext/gitdll/gitdll.c index 05271ad27..ceebc25d2 100644 --- a/ext/gitdll/gitdll.c +++ b/ext/gitdll/gitdll.c @@ -968,7 +968,10 @@ const char *get_windows_home_directory(void) home_directory = getenv("HOME"); if (home_directory && *home_directory) + { + home_directory = _strdup(home_directory); return home_directory; + } strbuf_addf(&buf, "%s%s", getenv("HOMEDRIVE"), getenv("HOMEPATH")); home_directory = strbuf_detach(&buf, NULL); -- 2.11.4.GIT