Skip to content

Commit cfeeab0

Browse files
alfredoyangkinetiknz
authored andcommitted
check add overflow
1 parent 7a10a83 commit cfeeab0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

mp4parse_capi/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,10 @@ impl<'a> Iterator for SampleToChunkIterator<'a> {
841841
self.sample_count = next.samples_per_chunk;
842842
// Total chunk number in 'stsc' could be different to 'stco',
843843
// there could be more chunks at the last 'stsc' record.
844-
((next.first_chunk - 1) .. next.first_chunk + self.remain_chunk_count -1)
844+
match next.first_chunk.checked_add(self.remain_chunk_count) {
845+
Some(r) => ((next.first_chunk - 1) .. r - 1),
846+
_ => (0 .. 0),
847+
}
845848
},
846849
_ => (0 .. 0),
847850
};

0 commit comments

Comments
 (0)