From: Ilia Alshanetsky <iliaa@php.net>
Date: Tue, 6 May 2008 18:04:25 +0000 (+0000)
Subject: MFB: Fixed bug #44836 (putenv() crashes, avoid direct reference of environ
X-Git-Tag: RELEASE_2_0_0b1~82
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7e68effe43c66cc8097419aba949660fbc2eb8ac;p=php

MFB: Fixed bug #44836 (putenv() crashes, avoid direct reference of environ
in POSIX systems).
---

diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index 358e8e821e..7b29618b27 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -3822,9 +3822,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);
@@ -4388,12 +4386,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;
 			}
 		}