mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
Merge branch 'PHP-7.2'
* PHP-7.2: Fix allocation Fix memory leak
This commit is contained in:
commit
89da3ed4d7
@ -4095,15 +4095,17 @@ PHP_FUNCTION(getenv)
|
||||
size = GetEnvironmentVariableW(keyw, &dummybuf, 0);
|
||||
if (GetLastError() == ERROR_ENVVAR_NOT_FOUND) {
|
||||
/* The environment variable doesn't exist. */
|
||||
free(keyw);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (size == 0) {
|
||||
/* env exists, but it is empty */
|
||||
free(keyw);
|
||||
RETURN_EMPTY_STRING();
|
||||
}
|
||||
|
||||
valw = emalloc(size);
|
||||
valw = emalloc((size + 1) * sizeof(wchar_t));
|
||||
size = GetEnvironmentVariableW(keyw, valw, size);
|
||||
if (size == 0) {
|
||||
/* has been removed between the two calls */
|
||||
|
Loading…
Reference in New Issue
Block a user