summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2018-01-13 12:33:02 +0100
committerAnatol Belski <ab@php.net>2018-01-13 12:33:02 +0100
commit1350f4f99725efa49725ad0d5a714e41a2db8e12 (patch)
treecf23376c192df5e90ad10f4a1d03dc15d9a4c923
parentcf70e1910b5079b4698ee2aeffe8201e429ea26a (diff)
parent2503a27ae088cf349775fa6dbd95ee1d3d764c79 (diff)
downloadphp-git-1350f4f99725efa49725ad0d5a714e41a2db8e12.tar.gz
Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1: Fix invalid free
-rw-r--r--sapi/cgi/cgi_main.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c
index 317a887cd4..8800788117 100644
--- a/sapi/cgi/cgi_main.c
+++ b/sapi/cgi/cgi_main.c
@@ -586,12 +586,20 @@ static char *sapi_fcgi_getenv(char *name, size_t name_len)
fcgi_request *request = (fcgi_request*) SG(server_context);
char *ret = fcgi_getenv(request, name, (int)name_len);
+#ifndef PHP_WIN32
if (ret) return ret;
/* if cgi, or fastcgi and not found in fcgi env
check the regular environment */
-#ifndef PHP_WIN32
return getenv(name);
#else
+ if (ret) {
+ /* The functions outside here don't know, where does it come
+ from. They'll need to free the returned memory as it's
+ not necessary from the fcgi env. */
+ return strdup(ret);
+ }
+ /* if cgi, or fastcgi and not found in fcgi env
+ check the regular environment */
return cgi_getenv_win32(name, name_len);
#endif
}