forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'simplify/b3' into simplify/w1a

Browse files at this commit

04c5f323eafd9b7e6949b5e876e35c144b5d1d8aAhmet Kaan GümüşParent: 5248f508e80cd7
crates/ec-h264/src/codec.rsmodified+7 -4
@@ -105,8 +105,7 @@ impl H264Decoder {
105 fn decode_packet_payload(&mut self, data: &[u8]) -> Result<()> {105 fn decode_packet_payload(&mut self, data: &[u8]) -> Result<()> {
106 let Some(size) = self.nal_length_size else {106 let Some(size) = self.nal_length_size else {
107 for unit in AnnexBIter::new(data) {107 for unit in AnnexBIter::new(data) {
108- let unit = unit.to_vec();108+ self.push(unit)?;
109- self.push(&unit)?;
110 }109 }
111 return Ok(());110 return Ok(());
112 };111 };
@@ -125,10 +124,14 @@ impl H264Decoder {
125 "H.264: a NAL unit of {length} bytes overruns the packet"124 "H.264: a NAL unit of {length} bytes overruns the packet"
126 ))125 ))
127 })?;126 })?;
128- let unit = data[offset..end].to_vec();127+ self.push(&data[offset..end])?;
129- self.push(&unit)?;
130 offset = end;128 offset = end;
131 }129 }
130+ if offset != data.len() {
131+ return Err(Error::corrupt(
132+ "H.264: trailing bytes too short for a NAL length field",
133+ ));
134+ }
132 Ok(())135 Ok(())
133 }136 }
134 137