From aa0e29a66838bd89547a5a8ec4ae25945556ad54 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Mon, 8 Jul 2019 16:07:45 +0000 Subject: [PATCH] CGI: Fix memory leak on error paths --- sapi/cgi/cgi_main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index a716b7cf3c..8978a8412b 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -1917,6 +1917,7 @@ int main(int argc, char *argv[]) #ifdef ZTS tsrm_shutdown(); #endif + free(bindpath); return FAILURE; } @@ -2339,6 +2340,7 @@ parent_loop_end: if (php_request_startup() == FAILURE) { SG(server_context) = NULL; php_module_shutdown(); + free(bindpath); return FAILURE; } if (no_headers) { @@ -2383,6 +2385,7 @@ parent_loop_end: if (php_request_startup() == FAILURE) { SG(server_context) = NULL; php_module_shutdown(); + free(bindpath); return FAILURE; } SG(headers_sent) = 1; @@ -2541,6 +2544,7 @@ parent_loop_end: #ifdef ZTS tsrm_shutdown(); #endif + free(bindpath); return FAILURE; } } @@ -2710,9 +2714,7 @@ fastcgi_request_done: requests++; if (max_requests && (requests == max_requests)) { fcgi_finish_request(request, 1); - if (bindpath) { - free(bindpath); - } + free(bindpath); if (max_requests != 1) { /* no need to return exit_status of the last request */ exit_status = 0; -- 2.40.0