diff --git a/compat/mingw.c b/compat/mingw.c index 1e5518ae37..a22cd5edc8 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -2495,6 +2495,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);