diff --git a/crates/ec-vp9-syntax/src/superframe.rs b/crates/ec-vp9-syntax/src/superframe.rs index d5a6c13d..44900f72 100644 --- a/crates/ec-vp9-syntax/src/superframe.rs +++ b/crates/ec-vp9-syntax/src/superframe.rs @@ -52,7 +52,9 @@ pub fn split(chunk: &[u8]) -> Result> { "VP9 superframe: frame {i} of {frames} runs past the chunk ({size} bytes at {offset})" )) })?; - out.push(&chunk[offset..end]); + if end > offset { + out.push(&chunk[offset..end]); + } offset = end; } Ok(out) @@ -102,6 +104,13 @@ mod tests { assert_eq!(frames[2][0], 2); } + #[test] + fn zero_size_entry_is_skipped() { + let chunk = pack(&[3, 0, 5], 1); + let frames = split(&chunk).unwrap(); + assert_eq!(frames.iter().map(|f| f.len()).collect::>(), [3, 5]); + } + #[test] fn oversized_entry_is_corrupt() { let mut chunk = pack(&[3, 5], 1);