Skip to content

Commit

Permalink
fix crashes reported by fuzz testing - mdia/hdlr not found
Browse files Browse the repository at this point in the history
  • Loading branch information
mindeng committed Jul 11, 2024
1 parent b9be79b commit 9708993
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/bbox/tkhd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,18 @@ pub fn parse_video_tkhd_in_moov<'a>(input: &'a [u8]) -> crate::Result<TkhdBox> {
Ok(tkhd)
}

fn find_video_track<'a>(input: &'a [u8]) -> crate::Result<BoxHolder<'a>> {
fn find_video_track(input: &[u8]) -> crate::Result<BoxHolder> {
let (_, bbox) = travel_while(input, |b| {
// find video track
if b.box_type() != "trak" {
true
} else {
let Some(hdlr) = find_box(b.body_data(), "mdia/hdlr").unwrap().1 else {
let found = find_box(b.body_data(), "mdia/hdlr");

let Ok(bbox) = found else {
return true;
};
let Some(hdlr) = bbox.1 else {
return true;
};

Expand All @@ -125,6 +130,7 @@ fn find_video_track<'a>(input: &'a [u8]) -> crate::Result<BoxHolder<'a>> {
}
})
.map_err(|e| format!("find vide trak failed: {e:?}"))?;

Ok(bbox)
}

Expand Down

0 comments on commit 9708993

Please sign in to comment.