1
0
Fork 0
mirror of https://github.com/alfg/mp4-rust.git synced 2024-06-02 13:39:54 +00:00

Fix order of arithmetic operations

This was due to an incorrect transcription when switching to checked
arithmetic, and fixes a bug that could cause attempted lookups of the wrong
chunk_id.
This commit is contained in:
Lilith Silvestris 2023-02-09 14:27:51 -08:00
parent e78dbf8f93
commit 3c318acded

View file

@ -453,8 +453,8 @@ impl Mp4Track {
let chunk_id = sample_id
.checked_sub(first_sample)
.and_then(|n| n.checked_add(first_chunk))
.map(|n| n / samples_per_chunk)
.and_then(|n| n.checked_add(first_chunk))
.ok_or(Error::InvalidData(
"attempt to calculate stsc chunk_id with overflow",
))?;