Use checked math when calculating storage size (#7885)

This commit is contained in:
Alexander Theißen
2021-01-14 13:44:42 +01:00
committed by GitHub
parent 65569620c2
commit c2ebcae0a6
5 changed files with 46 additions and 41 deletions
@@ -643,8 +643,7 @@ define_env!(Env, <E: Ext>,
let mut key: StorageKey = [0; 32];
ctx.read_sandbox_memory_into_buf(key_ptr, &mut key)?;
let value = Some(ctx.read_sandbox_memory(value_ptr, value_len)?);
ctx.ext.set_storage(key, value);
Ok(())
ctx.ext.set_storage(key, value).map_err(Into::into)
},
// Clear the value at the given key in the contract storage.
@@ -656,8 +655,7 @@ define_env!(Env, <E: Ext>,
ctx.charge_gas(RuntimeToken::ClearStorage)?;
let mut key: StorageKey = [0; 32];
ctx.read_sandbox_memory_into_buf(key_ptr, &mut key)?;
ctx.ext.set_storage(key, None);
Ok(())
ctx.ext.set_storage(key, None).map_err(Into::into)
},
// Retrieve the value under the given key from storage.