|
|
@@ -2290,8 +2290,10 @@ quit:
|
|
|
bool
|
|
|
wasm_module_validate(wasm_store_t *store, const wasm_byte_vec_t *binary)
|
|
|
{
|
|
|
+ wasm_byte_vec_t local_binary = { 0 };
|
|
|
struct WASMModuleCommon *module_rt;
|
|
|
char error_buf[128] = { 0 };
|
|
|
+ bool ret;
|
|
|
|
|
|
bh_assert(singleton_engine);
|
|
|
|
|
|
@@ -2300,15 +2302,26 @@ wasm_module_validate(wasm_store_t *store, const wasm_byte_vec_t *binary)
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- if ((module_rt = wasm_runtime_load((uint8 *)binary->data,
|
|
|
- (uint32)binary->size, error_buf, 128))) {
|
|
|
+ /* make a copy of binary */
|
|
|
+ wasm_byte_vec_new_uninitialized(&local_binary, binary->size);
|
|
|
+ if (binary->size && !local_binary.data)
|
|
|
+ return false;
|
|
|
+
|
|
|
+ wasm_byte_vec_copy(&local_binary, binary);
|
|
|
+
|
|
|
+ module_rt = wasm_runtime_load((uint8 *)local_binary.data,
|
|
|
+ (uint32)local_binary.size, error_buf, 128);
|
|
|
+ wasm_byte_vec_delete(&local_binary);
|
|
|
+ if (module_rt) {
|
|
|
wasm_runtime_unload(module_rt);
|
|
|
- return true;
|
|
|
+ ret = true;
|
|
|
}
|
|
|
else {
|
|
|
+ ret = false;
|
|
|
LOG_VERBOSE(error_buf);
|
|
|
- return false;
|
|
|
}
|
|
|
+
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
static void
|