mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-02-06 06:55:07 +00:00
Allocate correct space for results before native callback is run (#747)
This commit is contained in:
parent
e07b58062f
commit
b1173d1bfc
|
@ -4117,6 +4117,13 @@ wasm_runtime_invoke_c_api_native(WASMModuleInstanceCommon *module_inst,
|
|||
goto fail;
|
||||
}
|
||||
|
||||
if (func_type->result_count > 4
|
||||
&& !(results = wasm_runtime_malloc(sizeof(wasm_val_t)
|
||||
* func_type->result_count))) {
|
||||
wasm_runtime_set_exception(module_inst, "allocate memory failed");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!with_env) {
|
||||
wasm_func_callback_t callback = (wasm_func_callback_t)func_ptr;
|
||||
trap = callback(params, results);
|
||||
|
@ -4144,13 +4151,6 @@ wasm_runtime_invoke_c_api_native(WASMModuleInstanceCommon *module_inst,
|
|||
goto fail;
|
||||
}
|
||||
|
||||
if (func_type->result_count > 4
|
||||
&& !(results = wasm_runtime_malloc(sizeof(wasm_val_t)
|
||||
* func_type->result_count))) {
|
||||
wasm_runtime_set_exception(module_inst, "allocate memory failed");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!results_to_argv(module_inst, argv, results, func_type)) {
|
||||
wasm_runtime_set_exception(module_inst, "unsupported result type");
|
||||
goto fail;
|
||||
|
|
Loading…
Reference in New Issue
Block a user