diff --git a/compat/mingw.c b/compat/mingw.c index 0e0fcb46ed..59848ecde4 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -2390,6 +2390,17 @@ void mingw_startup(void) unset_environment_variables = xstrdup("PERL5LIB"); + /* + * Avoid a segmentation fault when cURL tries to set the CHARSET + * variable and putenv() barfs at our nedmalloc'ed environment. + */ + if (!getenv("CHARSET")) { + struct strbuf buf = STRBUF_INIT; + strbuf_addf(&buf, "cp%u", GetACP()); + setenv("CHARSET", buf.buf, 1); + strbuf_release(&buf); + } + /* initialize critical section for waitpid pinfo_t list */ InitializeCriticalSection(&pinfo_cs);