diff --git a/substrate/core/sr-io/without_std.rs b/substrate/core/sr-io/without_std.rs index cc20aff96a0c9cf5ce958300e2de42996cbcf3e9..c1bee278000e6f64d668fb25827f350db80ce625 100644 --- a/substrate/core/sr-io/without_std.rs +++ b/substrate/core/sr-io/without_std.rs @@ -283,9 +283,10 @@ pub fn child_storage_root(storage_key: &[u8]) -> Option<Vec<u8>> { if length == u32::max_value() { None } else { - let ret = slice::from_raw_parts(ptr, length as usize).to_vec(); - ext_free(ptr); - Some(ret) + // Invariants required by Vec::from_raw_parts are not formally fulfilled. + // We don't allocate via String/Vec<T>, but use a custom allocator instead. + // See #300 for more details. + Some(<Vec<u8>>::from_raw_parts(ptr, length as usize, length as usize)) } } }