Skip to content

Commit f5587ca

Browse files
dschoGit for Windows Build Agent
authored andcommitted
mingw: HOT FIX: work around environment issues -- again
This developer should really, really have known better. The fact that we are changing the environment in ways for which the MSVCRT is not prepared for is bad enough. But then this developer followed the request to re-enable nedmalloc -- despite the prediction that it would cause an access violation, predicting it in the same message as the request to re-enable nedmalloc, no less! To paper over the issue until the time when this developer finds the time to re-design the Unicode environment handling from scratch, let's hope that cURL is the only library we are using that *may* set an environment variable using MSVCRT's putenv() after we fscked the environment up. Note: this commit can serve as no source of pride to anyone, certainly not yours truly. It is necessary as a quick and pragmatic stop gap, though, to prevent worse problems. Note: cURL manages to set the variable CHARSET when nedmalloc is *not* enabled, without causing an access violation. In that case, it sets it successfully to the value "cp" + GetACP() (hence it is our choice, too, cURL may need it, Git does not): https://github.com/bagder/curl/blob/aa5808b5/lib/easy.c#L157-L162 Signed-off-by: Johannes Schindelin <[email protected]>
1 parent adb89a2 commit f5587ca

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

compat/mingw.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2350,6 +2350,17 @@ void mingw_startup(void)
23502350
/* fix Windows specific environment settings */
23512351
setup_windows_environment();
23522352

2353+
/*
2354+
* Avoid a segmentation fault when cURL tries to set the CHARSET
2355+
* variable and putenv() barfs at our nedmalloc'ed environment.
2356+
*/
2357+
if (!getenv("CHARSET")) {
2358+
struct strbuf buf = STRBUF_INIT;
2359+
strbuf_addf(&buf, "cp%u", GetACP());
2360+
setenv("CHARSET", buf.buf, 1);
2361+
strbuf_release(&buf);
2362+
}
2363+
23532364
/* initialize critical section for waitpid pinfo_t list */
23542365
InitializeCriticalSection(&pinfo_cs);
23552366

0 commit comments

Comments
 (0)