From 40a573445c9299819f6e8530526a91b8d9660864 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Thu, 4 Dec 2003 22:38:22 +0000 Subject: [PATCH] Work around a bug in putenv() in the VS.Net C run time library (MSVCRT71) where it will double free a string. --- ext/standard/basic_functions.c | 8 ++++++++ 1 file changed, 8 insertions(+) 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 -- 2.50.1