Skip to content

Commit 9959389

Browse files
committed
fix(*) resolve a possible segfault in the FFI
Creating the `rctx` can happen when no `wasm{}` block is configured (e.g. through the FFI in `init_worker`). For example, `set_host_properties_handlers()` might be called (wrong and unlikely, but possible). Always assume `rctx` might not be created due to a `wasm{}` block.
1 parent 8c45ad1 commit 9959389

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/http/ngx_http_wasm_module.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -584,11 +584,11 @@ ngx_http_wasm_rctx(ngx_http_request_t *r, ngx_http_wasm_req_ctx_t **out)
584584
rctx->sock_buffer_reuse = loc->socket_buffer_reuse;
585585
rctx->pwm_lua_resolver = loc->pwm_lua_resolver != NGX_CONF_UNSET
586586
? loc->pwm_lua_resolver
587-
: wcf->pwm_lua_resolver;
587+
: wcf ? wcf->pwm_lua_resolver : 0;
588588

589589
} else {
590590
/* fake request */
591-
rctx->pwm_lua_resolver = wcf->pwm_lua_resolver;
591+
rctx->pwm_lua_resolver = wcf ? wcf->pwm_lua_resolver : 0;
592592
}
593593
}
594594
#if (NGX_DEBUG)

src/wasm/ngx_wasm_core_module.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,9 @@ ngx_wasm_core_ssl_conf(ngx_cycle_t *cycle)
532532
ngx_wasm_core_conf_t *wcf;
533533

534534
wcf = ngx_wasm_core_cycle_get_conf(cycle);
535-
ngx_wasm_assert(wcf);
535+
if (wcf == NULL) {
536+
return NULL;
537+
}
536538

537539
return &wcf->ssl_conf;
538540
}

0 commit comments

Comments
 (0)