diff --git a/compat/mingw.c b/compat/mingw.c index f200a3cf70..57dfb22d3d 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -2319,6 +2319,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);