Skip to content

Commit 1350f4f

Browse files
committed
Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1: Fix invalid free
2 parents cf70e19 + 2503a27 commit 1350f4f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

sapi/cgi/cgi_main.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,12 +586,20 @@ static char *sapi_fcgi_getenv(char *name, size_t name_len)
586586
fcgi_request *request = (fcgi_request*) SG(server_context);
587587
char *ret = fcgi_getenv(request, name, (int)name_len);
588588

589+
#ifndef PHP_WIN32
589590
if (ret) return ret;
590591
/* if cgi, or fastcgi and not found in fcgi env
591592
check the regular environment */
592-
#ifndef PHP_WIN32
593593
return getenv(name);
594594
#else
595+
if (ret) {
596+
/* The functions outside here don't know, where does it come
597+
from. They'll need to free the returned memory as it's
598+
not necessary from the fcgi env. */
599+
return strdup(ret);
600+
}
601+
/* if cgi, or fastcgi and not found in fcgi env
602+
check the regular environment */
595603
return cgi_getenv_win32(name, name_len);
596604
#endif
597605
}

0 commit comments

Comments
 (0)