From: Wez Furlong Date: Thu, 4 Dec 2003 22:38:22 +0000 (+0000) Subject: Work around a bug in putenv() in the VS.Net C run time library (MSVCRT71) where it... X-Git-Tag: php-5.0.0b3RC1~313 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=40a573445c9299819f6e8530526a91b8d9660864;p=php Work around a bug in putenv() in the VS.Net C run time library (MSVCRT71) where it will double free a string. --- diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index fb1dbbec15..6f0b5f960d 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -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