From 16f6347264ac43ebe26e81a0780c0e83cf1e430b 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 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 */ -- 2.50.1