]> git.ipfire.org Git - thirdparty/git.git/blobdiff - compat/mingw.c
Merge branch 'bw/format-patch-o-create-leading-dirs'
[thirdparty/git.git] / compat / mingw.c
index 06566c8c882bf98a194a95d7d6d964e45e4f5857..6b765d936cfc8afe198b2735dafd4116c1706b58 100644 (file)
@@ -1665,6 +1665,8 @@ char *mingw_getenv(const char *name)
        if (!w_key)
                die("Out of memory, (tried to allocate %u wchar_t's)", len_key);
        xutftowcs(w_key, name, len_key);
+       /* GetEnvironmentVariableW() only sets the last error upon failure */
+       SetLastError(ERROR_SUCCESS);
        len_value = GetEnvironmentVariableW(w_key, w_value, ARRAY_SIZE(w_value));
        if (!len_value && GetLastError() == ERROR_ENVVAR_NOT_FOUND) {
                free(w_key);