mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Removed the unwrap to ensure the WASM instance can't crash the host
This commit is contained in:
parent
387daf8aea
commit
a12e554266
@ -54,10 +54,13 @@ impl PluginModule {
|
||||
}
|
||||
|
||||
fn raw_retrieve_action(env: &HostFunctionEnvironement, ptr: u32, len: u32) -> i64 {
|
||||
// TODO: Handle correctly the error
|
||||
let data: Retrieve = env.read_data(ptr as _, len).unwrap();
|
||||
let out = match env.read_data(ptr as _, len) {
|
||||
Ok(data) => retrieve_action(&env.ecs, data),
|
||||
Err(e) => Err(RetrieveError::BincodeError(e.to_string())),
|
||||
};
|
||||
|
||||
let out = retrieve_action(&env.ecs, data);
|
||||
// If an error happen set the i64 to 0 so the WASM side can tell an error
|
||||
// occured
|
||||
let (ptr, len) = env.write_data(&out).unwrap();
|
||||
to_i64(ptr, len as _)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user