Don't panic on packet data (#6769)

This commit is contained in:
Jack May
2019-11-06 14:32:37 -08:00
committed by GitHub
parent 29f3b198cf
commit 65de227520
4 changed files with 10 additions and 9 deletions

View File

@ -179,8 +179,8 @@ impl<'de, T: Deserialize<'de>> Deserialize<'de> for ShortVec<T> {
/// Return the decoded value and how many bytes it consumed.
pub fn decode_len(bytes: &[u8]) -> Result<(usize, usize), Box<bincode::ErrorKind>> {
let short_len: ShortU16 = bincode::deserialize(bytes)?;
let num_bytes = bincode::serialized_size(&short_len).unwrap() as usize;
Ok((short_len.0 as usize, num_bytes))
let num_bytes = bincode::serialized_size(&short_len)?;
Ok((short_len.0 as usize, num_bytes as usize))
}
#[cfg(test)]