This reverts commit 8917aca09469d45a4c0c6fe58b36a8eb5b572836.
WinAPI function GetEnvironmentVariableW() should not be used in CRT code as
it reads the variable from the process block, not from the CRT storage.
CRT storage and process block may be out of the sync, for example when
using the CRT's _environ[] access or the 3rd argument envp[] of the main()
function.
CRT getenv() function for CRT builds always returns correct value, so use
it instead of the WinAPI GetEnvironmentVariableW().
---
mingw-w64-crt/misc/getopt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mingw-w64-crt/misc/getopt.c b/mingw-w64-crt/misc/getopt.c
index fc317e34e84f..01b269d0a4d9 100644
--- a/mingw-w64-crt/misc/getopt.c
+++ b/mingw-w64-crt/misc/getopt.c
@@ -339,7 +339,7 @@ getopt_internal(int nargc, char * const *nargv, const char
*options,
* optreset != 0 for GNU compatibility.
*/
if (posixly_correct == -1 || optreset != 0)
- posixly_correct = (GetEnvironmentVariableW(L"POSIXLY_CORRECT",
NULL, 0) != 0);
+ posixly_correct = (getenv("POSIXLY_CORRECT") != NULL);
if (*options == '-')
flags |= FLAG_ALLARGS;
else if (posixly_correct || *options == '+')
--
2.20.1
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public