Skip to content

Commit 23409a4

Browse files
committed
Fixed crash on "php -b 1234 -unknown-option"
1 parent 3040a34 commit 23409a4

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

sapi/cgi/cgi_main.c

+4
Original file line numberDiff line numberDiff line change
@@ -1429,6 +1429,9 @@ consult the installation file that came with this distribution, or visit \n\
14291429
switch (c) {
14301430
case 'h':
14311431
case '?':
1432+
#if PHP_FASTCGI
1433+
fcgi_shutdown();
1434+
#endif
14321435
no_headers = 1;
14331436
php_output_startup();
14341437
php_output_activate(TSRMLS_C);
@@ -1823,6 +1826,7 @@ consult the installation file that came with this distribution, or visit \n\
18231826
}
18241827
/* end of fastcgi loop */
18251828
}
1829+
fcgi_shutdown();
18261830
#endif
18271831

18281832
if (cgi_sapi_module.php_ini_path_override) {

sapi/cgi/fastcgi.c

+5
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,11 @@ int fcgi_is_fastcgi(void)
255255
}
256256
}
257257

258+
void fcgi_shutdown(void)
259+
{
260+
is_fastcgi = 0;
261+
}
262+
258263
#ifdef _WIN32
259264
/* Do some black magic with the NT security API.
260265
* We prepare a DACL (Discretionary Access Control List) so that

sapi/cgi/fastcgi.h

+1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ typedef struct _fcgi_request {
112112
} fcgi_request;
113113

114114
int fcgi_init(void);
115+
void fcgi_shutdown(void);
115116
int fcgi_is_fastcgi(void);
116117
int fcgi_in_shutdown(void);
117118
int fcgi_listen(const char *path, int backlog);

0 commit comments

Comments
 (0)