Skip to content

Commit 2503a27

Browse files
committed
Fix invalid free
1 parent 8c07170 commit 2503a27

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

sapi/cgi/cgi_main.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -582,12 +582,20 @@ static char *sapi_fcgi_getenv(char *name, size_t name_len)
582582
fcgi_request *request = (fcgi_request*) SG(server_context);
583583
char *ret = fcgi_getenv(request, name, (int)name_len);
584584

585+
#ifndef PHP_WIN32
585586
if (ret) return ret;
586587
/* if cgi, or fastcgi and not found in fcgi env
587588
check the regular environment */
588-
#ifndef PHP_WIN32
589589
return getenv(name);
590590
#else
591+
if (ret) {
592+
/* The functions outside here don't know, where does it come
593+
from. They'll need to free the returned memory as it's
594+
not necessary from the fcgi env. */
595+
return strdup(ret);
596+
}
597+
/* if cgi, or fastcgi and not found in fcgi env
598+
check the regular environment */
591599
return cgi_getenv_win32(name, name_len);
592600
#endif
593601
}

0 commit comments

Comments
 (0)