Skip to content

Commit

Permalink
fix(*) resolve a possible segfault in the FFI
Browse files Browse the repository at this point in the history
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).

Always assume `rctx` might not be created due to a `wasm{}` block, since
the module is wider than Wasm support only.
  • Loading branch information
thibaultcha committed Nov 28, 2023
1 parent 3ff87db commit e1d5f46
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/http/ngx_http_wasm_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,11 +584,14 @@ ngx_http_wasm_rctx(ngx_http_request_t *r, ngx_http_wasm_req_ctx_t **out)
rctx->sock_buffer_reuse = loc->socket_buffer_reuse;
rctx->pwm_lua_resolver = loc->pwm_lua_resolver != NGX_CONF_UNSET
? loc->pwm_lua_resolver
: wcf->pwm_lua_resolver;
: wcf ? wcf->pwm_lua_resolver : NULL;

} else {
/* fake request */
rctx->pwm_lua_resolver = wcf->pwm_lua_resolver;

if (wcf) {
rctx->pwm_lua_resolver = wcf->pwm_lua_resolver;
}
}
}
#if (NGX_DEBUG)
Expand Down

0 comments on commit e1d5f46

Please sign in to comment.