From aeee365d72f9d14dec9430f6718e54d77c66c0a6 Mon Sep 17 00:00:00 2001 From: Pierre Joye Date: Mon, 26 Sep 2011 08:49:28 +0000 Subject: [PATCH] - be sure to check if the var ha not been removed between the two calls --- ext/standard/basic_functions.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index aecefa3d94..58e36c3cff 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -4022,7 +4022,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 */ -- 2.50.1