From: Antony Dovgal Date: Mon, 12 May 2008 08:47:01 +0000 (+0000) Subject: MFH: revert patch that causes invalid reads/crashes on Linux X-Git-Tag: BEFORE_NEW_PARAMETER_PARSE~236 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ea62779338c8223bdb178cd6388f52f0fb8bfd69;p=php MFH: revert patch that causes invalid reads/crashes on Linux --- diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 16222432ee..feb150ccd2 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -3820,7 +3820,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); @@ -4425,8 +4427,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 */ - /* must copy previous value because putenv can free the string without notice */ +#if defined(PHP_WIN32) + /* must copy previous value because MSVCRT's putenv can free the string without notice */ pe.previous_value = estrdup(*env); +#else + pe.previous_value = *env; +#endif break; } }