Skip to content

Commit a78e441

Browse files
baumanjkornelski
authored andcommitted
pixi reading improvements
1 parent f7b9ed0 commit a78e441

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

mp4parse/src/lib.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,11 +1656,15 @@ fn read_pixi<T: Read>(src: &mut BMFFBox<T>) -> Result<TryVec<u8>> {
16561656
return Err(Error::Unsupported("pixi version"));
16571657
}
16581658

1659-
let mut channels = TryVec::new();
1660-
let channel_count = src.read_u8()?;
1661-
for _ in 0..channel_count {
1662-
channels.push(src.read_u8()?)?;
1659+
let num_channels = src.read_u8()?.into();
1660+
let mut channels = TryVec::with_capacity(num_channels)?;
1661+
let num_channels_read = src.try_read_to_end(&mut channels)?;
1662+
1663+
if num_channels_read != num_channels.into() {
1664+
return Err(Error::InvalidData("invalid num_channels"));
16631665
}
1666+
1667+
check_parser_state!(src.content);
16641668
Ok(channels)
16651669
}
16661670

0 commit comments

Comments
 (0)