From ba2ffa834a4226205d8387e5d1b0ced04fb40572 Mon Sep 17 00:00:00 2001 From: John Plevyak Date: Thu, 6 Feb 2020 23:29:17 +0000 Subject: [PATCH] Return the foreign function result. Signed-off-by: John Plevyak --- source/extensions/common/wasm/exports.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/extensions/common/wasm/exports.cc b/source/extensions/common/wasm/exports.cc index 7f24914dce63..df03669761de 100644 --- a/source/extensions/common/wasm/exports.cc +++ b/source/extensions/common/wasm/exports.cc @@ -237,7 +237,7 @@ Word call_foreign_function(void* raw_context, Word function_name, Word function_ uint64_t address = 0; void* result = nullptr; size_t result_size = 0; - f(wasm, args, [&wasm, &address, &result, &result_size](size_t s) -> void* { + auto res = f(wasm, args, [&wasm, &address, &result, &result_size](size_t s) -> void* { result = wasm.allocMemory(s, &address); result_size = s; return result; @@ -248,7 +248,7 @@ Word call_foreign_function(void* raw_context, Word function_name, Word function_ if (!context->wasmVm()->setWord(results_size.u64_, Word(result_size))) { return wasmResultToWord(WasmResult::InvalidMemoryAccess); } - return wasmResultToWord(WasmResult::Ok); + return wasmResultToWord(res); } Word clear_route_cache(void* raw_context) {