diff --git a/compat/mingw.c b/compat/mingw.c index 165ace09ad..10ade6c6f6 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -2336,6 +2336,17 @@ void mingw_startup() if (!getenv("TERM")) setenv("TERM", "cygwin", 1); + /* + * 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);