protect against corruption (#4741)
This commit is contained in:
parent
c228792967
commit
3600a926df
|
@ -65,6 +65,9 @@ impl Account {
|
|||
}
|
||||
|
||||
pub fn serialize_data<T: serde::Serialize>(&mut self, state: &T) -> Result<(), bincode::Error> {
|
||||
if bincode::serialized_size(state)? > self.data.len() as u64 {
|
||||
return Err(Box::new(bincode::ErrorKind::SizeLimit));
|
||||
}
|
||||
bincode::serialize_into(&mut self.data[..], state)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue