Skip to content

Commit 4be9cdf

Browse files
committed
Skip the rest of userdata box if we encounter an error while parsing it.
This adjusts the behaviour when parsing invalid data in the userdata box. Prior to this change we'd fail as the parser would be left in a state we consided invalid. By skipping the rest of the box we instead continue to parse, and just ignore the userdata.
1 parent 26af474 commit 4be9cdf

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

mp4parse/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2344,6 +2344,11 @@ fn read_moov<T: Read>(f: &mut BMFFBox<T>, context: Option<MediaContext>) -> Resu
23442344
BoxType::UserdataBox => {
23452345
userdata = Some(read_udta(&mut b));
23462346
debug!("{:?}", userdata);
2347+
if let Some(Err(_)) = userdata {
2348+
// There was an error parsing userdata. Such failures are not fatal to overall
2349+
// parsing, just skip the rest of the box.
2350+
skip_box_remain(&mut b)?;
2351+
}
23472352
}
23482353
_ => skip_box_content(&mut b)?,
23492354
};

0 commit comments

Comments
 (0)