]> granicus.if.org Git - php/commitdiff
Work around a bug in putenv() in the VS.Net C run time library (MSVCRT71) where it...
authorWez Furlong <wez@php.net>
Thu, 4 Dec 2003 22:38:22 +0000 (22:38 +0000)
committerWez Furlong <wez@php.net>
Thu, 4 Dec 2003 22:38:22 +0000 (22:38 +0000)
ext/standard/basic_functions.c

index fb1dbbec154ad6a6601c512652dc64b5163d6569..6f0b5f960d126a147c40e6b80523694a22c28a8f 100644 (file)
@@ -1448,6 +1448,14 @@ PHP_FUNCTION(putenv)
                        }
                }
 
+#if _MSC_VER >= 1300
+               /* VS.Net has a bug in putenv() when setting a variable that
+                * is already set; if the SetEnvironmentVariable() API call
+                * fails, the Crt will double free() a string.
+                * We try to avoid this by setting our own value first */
+               SetEnvironmentVariable(pe.key, "bugbug");
+#endif
+               
                if (putenv(pe.putenv_string) == 0) {    /* success */
                        zend_hash_add(&BG(putenv_ht), pe.key, pe.key_len+1, (void **) &pe, sizeof(putenv_entry), NULL);
 #ifdef HAVE_TZSET