gstreamer: bufferlist: Check index/length when removing a buffer

Out of range values give assertions in the C function.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1444>
This commit is contained in:
Sebastian Dröge 2024-05-21 08:13:18 +03:00
parent 9f151466b7
commit a0e58ec359

View file

@ -44,6 +44,10 @@ impl BufferListRef {
#[doc(alias = "gst_buffer_list_remove")]
pub fn remove(&mut self, idx: u32, len: u32) {
let n = self.len() as u32;
assert!(idx < n);
assert!(idx.checked_add(len).unwrap() <= n);
unsafe { ffi::gst_buffer_list_remove(self.as_mut_ptr(), idx, len) }
}