diff --git a/package.json b/package.json index 2b6a421..efe864f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ssvm", - "version": "0.5.0", + "version": "0.5.1", "description": "Second State WebAssembly VM for Node.js Addon", "keywords": [ "wasm", diff --git a/ssvmaddon.cc b/ssvmaddon.cc index 7a5a381..e5d47e5 100644 --- a/ssvmaddon.cc +++ b/ssvmaddon.cc @@ -698,10 +698,17 @@ void SSVMAddon::EnableWasmBindgen(const Napi::CallbackInfo &Info) { Napi::Env Env = Info.Env(); Napi::HandleScope Scope(Env); - if ((IMode == InputMode::FilePath && !(VM->loadWasm(InputPath))) - || (IMode == InputMode::WasmBytecode && !(VM->loadWasm(InputBytecode)))) { + if (IMode == InputMode::FilePath && !(VM->loadWasm(InputPath))) { napi_throw_error(Info.Env(), "Error", "Wasm bytecode/file cannot be loaded correctly."); return; + } else if (IMode == InputMode::WasmBytecode) { + if (EnableAOT && !(VM->loadWasm(InputPath))) { + napi_throw_error(Info.Env(), "Error", "Wasm bytecode/file cannot be loaded correctly."); + return; + } else if (!EnableAOT && !(VM->loadWasm(InputBytecode))) { + napi_throw_error(Info.Env(), "Error", "Wasm bytecode/file cannot be loaded correctly."); + return; + } } if (!(VM->validate())) {