mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-27 15:41:33 +00:00
Clone import in instantiate to prevent import move
This commit is contained in:
@ -467,7 +467,7 @@ pub unsafe extern "C" fn wasmer_instantiate(
|
||||
wasmer_import_export_kind::WASM_GLOBAL => import.value.global as *mut Export,
|
||||
wasmer_import_export_kind::WASM_TABLE => import.value.table as *mut Export,
|
||||
};
|
||||
namespace.insert(import_name, unsafe { *Box::from_raw(export) }); // TODO Review
|
||||
namespace.insert(import_name, unsafe { (&*export).clone() });
|
||||
}
|
||||
for (module_name, namespace) in namespaces.into_iter() {
|
||||
import_object.register(module_name, namespace);
|
||||
@ -488,7 +488,6 @@ pub unsafe extern "C" fn wasmer_instantiate(
|
||||
}
|
||||
};
|
||||
unsafe { *instance = Box::into_raw(Box::new(new_instance)) as *mut wasmer_instance_t };
|
||||
Box::into_raw(Box::new(import_object));
|
||||
wasmer_result_t::WASMER_OK
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ int main()
|
||||
assert(0 == strcmp(actual_str, "Hello, World!"));
|
||||
|
||||
printf("Destroying func\n");
|
||||
// wasmer_func_destroy(func);
|
||||
wasmer_func_destroy(func);
|
||||
printf("Destroy instance\n");
|
||||
wasmer_instance_destroy(instance);
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user