Skip to content

Commit aa0e29a

Browse files
devnexennikic
authored andcommitted
CGI: Fix memory leak on error paths
1 parent 8f0c87e commit aa0e29a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

sapi/cgi/cgi_main.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,6 +1917,7 @@ int main(int argc, char *argv[])
19171917
#ifdef ZTS
19181918
tsrm_shutdown();
19191919
#endif
1920+
free(bindpath);
19201921
return FAILURE;
19211922
}
19221923

@@ -2339,6 +2340,7 @@ consult the installation file that came with this distribution, or visit \n\
23392340
if (php_request_startup() == FAILURE) {
23402341
SG(server_context) = NULL;
23412342
php_module_shutdown();
2343+
free(bindpath);
23422344
return FAILURE;
23432345
}
23442346
if (no_headers) {
@@ -2383,6 +2385,7 @@ consult the installation file that came with this distribution, or visit \n\
23832385
if (php_request_startup() == FAILURE) {
23842386
SG(server_context) = NULL;
23852387
php_module_shutdown();
2388+
free(bindpath);
23862389
return FAILURE;
23872390
}
23882391
SG(headers_sent) = 1;
@@ -2541,6 +2544,7 @@ consult the installation file that came with this distribution, or visit \n\
25412544
#ifdef ZTS
25422545
tsrm_shutdown();
25432546
#endif
2547+
free(bindpath);
25442548
return FAILURE;
25452549
}
25462550
}
@@ -2710,9 +2714,7 @@ consult the installation file that came with this distribution, or visit \n\
27102714
requests++;
27112715
if (max_requests && (requests == max_requests)) {
27122716
fcgi_finish_request(request, 1);
2713-
if (bindpath) {
2714-
free(bindpath);
2715-
}
2717+
free(bindpath);
27162718
if (max_requests != 1) {
27172719
/* no need to return exit_status of the last request */
27182720
exit_status = 0;

0 commit comments

Comments
 (0)