summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfoobar <sniper@php.net>2005-05-08 19:50:39 +0000
committerfoobar <sniper@php.net>2005-05-08 19:50:39 +0000
commit79cbb4b14303761995d4241ee3a1841852144d46 (patch)
treec7e7f8ebda8bfee93cc9dcbf63b1e46d7bce6c1b
parentfcfd9f78abf7ff741e5ce85371e578806a9e576f (diff)
downloadphp-git-79cbb4b14303761995d4241ee3a1841852144d46.tar.gz
MFH: - Fixed putenv() under win32 (see bug #32957)
-rw-r--r--ext/standard/basic_functions.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index 7ef15f34e4..60ea17b70b 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -944,6 +944,13 @@ zend_module_entry basic_functions_module = {
static void php_putenv_destructor(putenv_entry *pe)
{
if (pe->previous_value) {
+#if _MSC_VER
+ /* 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
putenv(pe->previous_value);
} else {
# if HAVE_UNSETENV
@@ -1430,6 +1437,14 @@ PHP_FUNCTION(putenv)
}
}
+#if _MSC_VER
+ /* 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