]> granicus.if.org Git - php/commitdiff
Fixed bug #44836 (putenv() crashes, avoid direct reference of environ in
authorIlia Alshanetsky <iliaa@php.net>
Tue, 6 May 2008 18:01:32 +0000 (18:01 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Tue, 6 May 2008 18:01:32 +0000 (18:01 +0000)
POSIX systems)

# Original patch by delphij at FreeBSD dot org

ext/standard/basic_functions.c

index f5ddeab8278160fdb286e20291b216c829991463..780e576d33c8c3c71ab60ae6cf5155939b599c93 100644 (file)
@@ -3820,9 +3820,7 @@ 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);
@@ -4427,12 +4425,8 @@ 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 */
+                               /* must copy previous value because putenv can free the string without notice */
                                pe.previous_value = estrdup(*env);
-#else
-                               pe.previous_value = *env;
-#endif
                                break;
                        }
                }