From 42e1c9a1e0abf96b0501f067e83fcd7505331b67 Mon Sep 17 00:00:00 2001 From: Edin Kadribasic Date: Sun, 10 Dec 2006 01:23:41 +0000 Subject: [PATCH] Fixed by #39751 by KevinJohnHoffman at gmail dot com --- 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 a61d7c7034..977f59cece 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -3837,6 +3837,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); @@ -4430,7 +4433,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; } } -- 2.40.0