summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--docs/changes.xml7
-rw-r--r--src/nxt_php_sapi.c7
2 files changed, 12 insertions, 2 deletions
diff --git a/docs/changes.xml b/docs/changes.xml
index b3803ffe..1d4b9645 100644
--- a/docs/changes.xml
+++ b/docs/changes.xml
@@ -45,6 +45,13 @@ appeared in 1.26.0.
</para>
</change>
+<change type="bugfix">
+<para>
+a segmentation fault occurred in the PHP module if chdir() or
+fastcgi_finish_request() was called in the OPcache preloading script.
+</para>
+</change>
+
</changes>
diff --git a/src/nxt_php_sapi.c b/src/nxt_php_sapi.c
index ea5f5581..68ef07eb 100644
--- a/src/nxt_php_sapi.c
+++ b/src/nxt_php_sapi.c
@@ -204,7 +204,10 @@ ZEND_NAMED_FUNCTION(nxt_php_chdir)
nxt_php_run_ctx_t *ctx;
ctx = SG(server_context);
- ctx->chdir = 1;
+
+ if (nxt_fast_path(ctx != NULL)) {
+ ctx->chdir = 1;
+ }
nxt_php_chdir_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
@@ -225,7 +228,7 @@ PHP_FUNCTION(fastcgi_finish_request)
ctx = SG(server_context);
- if (nxt_slow_path(ctx->req == NULL)) {
+ if (nxt_slow_path(ctx == NULL || ctx->req == NULL)) {
RETURN_FALSE;
}