mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-09 06:08:29 +00:00
fix(c-api) Restore a bug with wasi_get_imports.
We said that `wasi_get_imports` was taking ownership of
`wasi_env_t`. It wasn't. In 9e63ba9a25,
we have fixed this. But it creates another bug when `wasi_env_t` is
used _after_ for example when calling `wasi_env_read_stdout`.
So this patch reverts the bug fix. And we will discuss about how to
fix that later.
This commit is contained in:
@@ -479,13 +479,11 @@ pub extern "C" fn wasm_named_extern_unwrap(
|
|||||||
/// implementation with no particular order. Each import has its
|
/// implementation with no particular order. Each import has its
|
||||||
/// associated module name and name, so that it can be re-order later
|
/// associated module name and name, so that it can be re-order later
|
||||||
/// based on the `wasm_module_t` requirements.
|
/// based on the `wasm_module_t` requirements.
|
||||||
///
|
|
||||||
/// This function takes ownership of `wasm_env_t`.
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasi_get_unordered_imports(
|
pub unsafe extern "C" fn wasi_get_unordered_imports(
|
||||||
store: Option<&wasm_store_t>,
|
store: Option<&wasm_store_t>,
|
||||||
module: Option<&wasm_module_t>,
|
module: Option<&wasm_module_t>,
|
||||||
wasi_env: Option<Box<wasi_env_t>>,
|
wasi_env: Option<&wasi_env_t>,
|
||||||
imports: &mut wasm_named_extern_vec_t,
|
imports: &mut wasm_named_extern_vec_t,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
wasi_get_unordered_imports_inner(store, module, wasi_env, imports).is_some()
|
wasi_get_unordered_imports_inner(store, module, wasi_env, imports).is_some()
|
||||||
@@ -494,7 +492,7 @@ pub unsafe extern "C" fn wasi_get_unordered_imports(
|
|||||||
fn wasi_get_unordered_imports_inner(
|
fn wasi_get_unordered_imports_inner(
|
||||||
store: Option<&wasm_store_t>,
|
store: Option<&wasm_store_t>,
|
||||||
module: Option<&wasm_module_t>,
|
module: Option<&wasm_module_t>,
|
||||||
wasi_env: Option<Box<wasi_env_t>>,
|
wasi_env: Option<&wasi_env_t>,
|
||||||
imports: &mut wasm_named_extern_vec_t,
|
imports: &mut wasm_named_extern_vec_t,
|
||||||
) -> Option<()> {
|
) -> Option<()> {
|
||||||
let store = store?;
|
let store = store?;
|
||||||
@@ -535,23 +533,20 @@ fn wasi_get_unordered_imports_inner(
|
|||||||
|
|
||||||
/// Non-standard function to get the imports needed for the WASI
|
/// Non-standard function to get the imports needed for the WASI
|
||||||
/// implementation ordered as expected by the `wasm_module_t`.
|
/// implementation ordered as expected by the `wasm_module_t`.
|
||||||
///
|
|
||||||
/// This function takes ownership of `wasm_env_t`.
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasi_get_imports(
|
pub unsafe extern "C" fn wasi_get_imports(
|
||||||
store: Option<&wasm_store_t>,
|
store: Option<&wasm_store_t>,
|
||||||
module: Option<&wasm_module_t>,
|
module: Option<&wasm_module_t>,
|
||||||
wasi_env: Option<Box<wasi_env_t>>,
|
wasi_env: Option<&wasi_env_t>,
|
||||||
imports: &mut wasm_extern_vec_t,
|
imports: &mut wasm_extern_vec_t,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
wasi_get_imports_inner(store, module, wasi_env, imports).is_some()
|
wasi_get_imports_inner(store, module, wasi_env, imports).is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Takes ownership of `wasi_env_t`.
|
|
||||||
fn wasi_get_imports_inner(
|
fn wasi_get_imports_inner(
|
||||||
store: Option<&wasm_store_t>,
|
store: Option<&wasm_store_t>,
|
||||||
module: Option<&wasm_module_t>,
|
module: Option<&wasm_module_t>,
|
||||||
wasi_env: Option<Box<wasi_env_t>>,
|
wasi_env: Option<&wasi_env_t>,
|
||||||
imports: &mut wasm_extern_vec_t,
|
imports: &mut wasm_extern_vec_t,
|
||||||
) -> Option<()> {
|
) -> Option<()> {
|
||||||
let store = store?;
|
let store = store?;
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ void wasi_env_set_memory(wasi_env_t *_env,
|
|||||||
#if defined(WASMER_WASI_ENABLED)
|
#if defined(WASMER_WASI_ENABLED)
|
||||||
bool wasi_get_imports(const wasm_store_t *store,
|
bool wasi_get_imports(const wasm_store_t *store,
|
||||||
const wasm_module_t *module,
|
const wasm_module_t *module,
|
||||||
wasi_env_t *wasi_env,
|
const wasi_env_t *wasi_env,
|
||||||
wasm_extern_vec_t *imports);
|
wasm_extern_vec_t *imports);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -237,7 +237,7 @@ wasm_func_t *wasi_get_start_function(wasm_instance_t *instance);
|
|||||||
#if defined(WASMER_WASI_ENABLED)
|
#if defined(WASMER_WASI_ENABLED)
|
||||||
bool wasi_get_unordered_imports(const wasm_store_t *store,
|
bool wasi_get_unordered_imports(const wasm_store_t *store,
|
||||||
const wasm_module_t *module,
|
const wasm_module_t *module,
|
||||||
wasi_env_t *wasi_env,
|
const wasi_env_t *wasi_env,
|
||||||
wasm_named_extern_vec_t *imports);
|
wasm_named_extern_vec_t *imports);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user