From: Edin Kadribasic Date: Sun, 10 Dec 2006 01:24:13 +0000 (+0000) Subject: MFB: Fixed by #39751 by KevinJohnHoffman at gmail dot com X-Git-Tag: RELEASE_1_0_0RC1~739 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5ac9df24b69f3aeab99512591d2e69bce0e79f55;p=php MFB: Fixed by #39751 by KevinJohnHoffman at gmail dot com --- diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 75abd04539..fe9451a687 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -3852,6 +3852,9 @@ static void php_putenv_destructor(putenv_entry *pe) SetEnvironmentVariable(pe->key, "bugbug"); #endif putenv(pe->previous_value); +# if defined(PHP_WIN32) + efree(pe->previous_value); +# endif } else { # if HAVE_UNSETENV unsetenv(pe->key); @@ -4419,7 +4422,12 @@ PHP_FUNCTION(putenv) pe.previous_value = NULL; for (env = environ; env != NULL && *env != NULL; env++) { if (!strncmp(*env, pe.key, pe.key_len) && (*env)[pe.key_len] == '=') { /* found it */ +#if defined(PHP_WIN32) + /* must copy previous value because MSVCRT's putenv can free the string without notice */ + pe.previous_value = estrndup(*env, 1024); +#else pe.previous_value = *env; +#endif break; } }