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/1447>
This commit is contained in:
Sebastian Dröge 2024-05-21 08:13:18 +03:00
parent 61b69db8e1
commit 4ca6dc3853

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) }
}