diff --git a/src/consensus/encode.rs b/src/consensus/encode.rs index 90e4d2f1..7620137a 100644 --- a/src/consensus/encode.rs +++ b/src/consensus/encode.rs @@ -659,6 +659,12 @@ impl Decodable for CheckedData { #[inline] fn consensus_decode(d: &mut D) -> Result { let len: u32 = Decodable::consensus_decode(d)?; + if len > MAX_VEC_SIZE as u32 { + return Err(self::Error::OversizedVectorAllocation { + requested: len as usize, + max: MAX_VEC_SIZE + }); + } let checksum: [u8; 4] = Decodable::consensus_decode(d)?; let mut ret = Vec::with_capacity(len as usize); ret.resize(len as usize, 0);