- 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,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 */