From: Dmitry Volyntsev Date: Thu, 5 Nov 2026 00:44:13 +0000 (-0800) Subject: Modules: use the caller context for QuickJS string conversion X-Git-Url: https://git.kaiwu.me/%7B@url%7D?a=commitdiff_plain;h=c3a0132eaf69a51873d6d6635e9b277484eb9609;p=njs.git Modules: use the caller context for QuickJS string conversion String conversion recovered the context through ctx->engine even though both the JSContext and destination pool were already supplied. During module evaluation the engine is not published yet, so synchronous Request and Headers construction could dereference NULL. Use the supplied context without changing allocation or copy behavior. The dependency was introduced in 201b1276. --- diff --git a/nginx/ngx_js.c b/nginx/ngx_js.c index 1ba8f712..77fd0b26 100644 --- a/nginx/ngx_js.c +++ b/nginx/ngx_js.c @@ -1694,11 +1694,6 @@ ngx_qjs_string(JSContext *cx, ngx_pool_t *pool, JSValueConst val, u_char *start; JSValue buffer; const char *str; - ngx_js_ctx_t *ctx; - ngx_engine_t *e; - - ctx = ngx_qjs_external_ctx(cx, JS_GetContextOpaque(cx)); - e = ctx->engine; if (JS_IsNullOrUndefined(val)) { dst->data = NULL; @@ -1706,8 +1701,6 @@ ngx_qjs_string(JSContext *cx, ngx_pool_t *pool, JSValueConst val, return NGX_OK; } - cx = e->u.qjs.ctx; - if (JS_IsString(val)) { goto string; }