Skip to content

Commit eb54606

Browse files
committed
ffi: Assert that the read callback does not return more bytes than requested.
1 parent 5d9528d commit eb54606

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

mp4parse_capi/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ impl Read for Mp4parseIo {
499499
}
500500
let rv = self.read.unwrap()(buf.as_mut_ptr(), buf.len(), self.userdata);
501501
if rv >= 0 {
502+
assert!(rv as usize <= buf.len(), "read callback returned more bytes than buffer size");
502503
Ok(rv as usize)
503504
} else {
504505
Err(std::io::Error::other("I/O error in Mp4parseIo Read impl"))

0 commit comments

Comments
 (0)