From: Pierre Joye Date: Mon, 26 Sep 2011 08:49:28 +0000 (+0000) Subject: - be sure to check if the var ha not been removed between the two calls X-Git-Tag: php-5.5.0alpha1~1068 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=16f6347264ac43ebe26e81a0780c0e83cf1e430b;p=php - be sure to check if the var ha not been removed between the two calls --- diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 18282a8daa..568e719e03 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -4024,7 +4024,13 @@ PHP_FUNCTION(getenv) ptr = emalloc(size); size = GetEnvironmentVariableA(str, ptr, size); - RETURN_STRING(ptr, 0); + if (size == 0) { + /* has been removed between the two calls */ + efree(ptr); + RETURN_EMPTY_STRING(); + } else { + RETURN_STRING(ptr, 0); + } } #else /* system method returns a const */