Skip to content

Commit

Permalink
Merge pull request #14 from onkoe/fix/build_32_bit_targets_2
Browse files Browse the repository at this point in the history
  • Loading branch information
mindeng authored Sep 28, 2024
2 parents a421a7f + 9444a6b commit cb04a5f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/bbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@ impl<'a> BoxHolder<'a> {
pub fn parse(input: &'a [u8]) -> IResult<&'a [u8], BoxHolder<'a>> {
let (_, header) = BoxHeader::parse(input)?;
tracing::debug!(box_type = header.box_type, ?header, "Got");
let (remain, data) = streaming::take(header.box_size)(input)?;

let box_size = usize::try_from(header.box_size)
.expect("header box size should always fit into a `usize`.");

let (remain, data) = streaming::take(box_size)(input)?;

Ok((remain, BoxHolder { header, data }))
}
Expand Down
5 changes: 4 additions & 1 deletion src/bbox/idat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ pub struct IdatBox<'a> {
impl<'a> IdatBox<'a> {
pub fn parse(input: &'a [u8]) -> IResult<&'a [u8], IdatBox> {
let (remain, header) = BoxHeader::parse(input)?;
let (remain, data) = streaming::take(header.box_size - header.header_size as u64)(remain)?;

let box_size = usize::try_from(header.box_size).expect("box size must fit into a `usize`.");

let (remain, data) = streaming::take(box_size - header.header_size)(remain)?;

Ok((remain, IdatBox { header, data }))
}
Expand Down

0 comments on commit cb04a5f

Please sign in to comment.