Fix sandbox::Memory lifecycle + sandox get memory function for no_std env (#845)

* Fix `sandbox::Memory` lifecycle for no_std env

* Retain memories in env_def builder and instance

* Add scoped memory creation to test RC semantics

* Add deploying_wasm_contract_should_work test.

* Fix sandboxed memory set function.
This commit is contained in:
Sergey Pepyakin
2018-09-30 17:23:32 +01:00
committed by Gav Wood
parent a5a7dd2480
commit 2414ffdac0
6 changed files with 238 additions and 25 deletions
+2 -2
View File
@@ -438,11 +438,11 @@ impl_function_executor!(this: FunctionExecutor<'e, E>,
ext_sandbox_memory_set(memory_idx: u32, offset: u32, val_ptr: *const u8, val_len: usize) -> u32 => {
let dst_memory = this.sandbox_store.memory(memory_idx)?;
let data = match this.memory.get(offset, val_len as usize) {
let data = match this.memory.get(val_ptr, val_len as usize) {
Ok(data) => data,
Err(_) => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS),
};
match dst_memory.set(val_ptr, &data) {
match dst_memory.set(offset, &data) {
Err(_) => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS),
_ => {},
}