summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Joye <pajoye@php.net>2011-09-26 08:49:28 +0000
committerPierre Joye <pajoye@php.net>2011-09-26 08:49:28 +0000
commitaeee365d72f9d14dec9430f6718e54d77c66c0a6 (patch)
treec0713dd2f5c3aa3f58ed28cf4e566f55fdc1c6c1
parent3e0e2820b8d5b75214e4e854aa51aba1d47b109e (diff)
downloadphp-git-aeee365d72f9d14dec9430f6718e54d77c66c0a6.tar.gz
- be sure to check if the var ha not been removed between the two calls
-rw-r--r--ext/standard/basic_functions.c8
1 files changed, 7 insertions, 1 deletions
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 */