diff --git a/src/wasm/wasi/ngx_wasi_host.c b/src/wasm/wasi/ngx_wasi_host.c index 3af0b6d6a..0924b7219 100644 --- a/src/wasm/wasi/ngx_wasi_host.c +++ b/src/wasm/wasi/ngx_wasi_host.c @@ -258,7 +258,11 @@ ngx_wasi_hfuncs_fd_write(ngx_wavm_instance_t *instance, /* second pass: build string from iov buffers */ - msg_data = ngx_pcalloc(instance->pool, msg_size); + /** + * TODO: replace with a host-pointer-provided pool when possible; + * see https://github.com/Kong/ngx_wasm_module/pull/457 + */ + msg_data = ngx_alloc(msg_size, instance->log); if (msg_data == NULL) { rets[0] = (wasm_val_t) WASM_I32_VAL(WASI_ERRNO_EFAULT); return NGX_WAVM_OK; @@ -291,6 +295,8 @@ ngx_wasi_hfuncs_fd_write(ngx_wavm_instance_t *instance, msg_size, msg_data); } + ngx_free(msg_data); + rets[0] = (wasm_val_t) WASM_I32_VAL(WASI_ERRNO_SUCCESS); return NGX_WAVM_OK; }