- be sure to check if the var ha not been removed between the two calls

This commit is contained in:
Pierre Joye 2011-09-26 08:49:28 +00:00
parent 3e0e2820b8
commit aeee365d72

View file

@ -4022,8 +4022,14 @@ PHP_FUNCTION(getenv)
ptr = emalloc(size); ptr = emalloc(size);
size = GetEnvironmentVariableA(str, ptr, size); size = GetEnvironmentVariableA(str, ptr, size);
if (size == 0) {
/* has been removed between the two calls */
efree(ptr);
RETURN_EMPTY_STRING();
} else {
RETURN_STRING(ptr, 0); RETURN_STRING(ptr, 0);
} }
}
#else #else
/* system method returns a const */ /* system method returns a const */
ptr = getenv(str); ptr = getenv(str);