summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2020-05-11 10:41:30 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2020-05-11 10:41:30 (GMT)
commit22648e5ebc9138abf5aba928db74520ac22f23ab (patch)
tree8f01bc6acb3bce228bab2c60c5f7e1a238f6b8b4 /generic
parent783b10ecec013f3f096ca5cc2f56b628db6b2fce (diff)
downloadtcl-22648e5ebc9138abf5aba928db74520ac22f23ab.zip
tcl-22648e5ebc9138abf5aba928db74520ac22f23ab.tar.gz
tcl-22648e5ebc9138abf5aba928db74520ac22f23ab.tar.bz2
Fix [d402ffe76]: Win32 potential crash when using main(). Thanks to Christian Werner for the Bug report and the Fix.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclEnv.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/generic/tclEnv.c b/generic/tclEnv.c
index 1f61e07..15dd8b5 100644
--- a/generic/tclEnv.c
+++ b/generic/tclEnv.c
@@ -127,6 +127,17 @@ TclSetupEnv(
/*msg*/ 0, /*createPart1*/ 0, /*createPart2*/ 0, &arrayPtr);
TclFindArrayPtrElements(varPtr, &namesHash);
+#if defined(_WIN32)
+ if (tenviron == NULL) {
+ /*
+ * When we are started from main(), the _wenviron array could
+ * be NULL and will be initialized by the first _wgetenv() call.
+ */
+
+ (void) _wgetenv(L"WINDIR");
+ }
+#endif
+
/*
* Go through the environment array and transfer its values into Tcl. At
* the same time, remove those elements we add/update from the hash table