From a0e58ec359954198d1f06cc970d1f3136d88b859 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 21 May 2024 08:13:18 +0300 Subject: [PATCH] gstreamer: bufferlist: Check index/length when removing a buffer Out of range values give assertions in the C function. Part-of: --- gstreamer/src/bufferlist.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gstreamer/src/bufferlist.rs b/gstreamer/src/bufferlist.rs index d837111fe..24851e692 100644 --- a/gstreamer/src/bufferlist.rs +++ b/gstreamer/src/bufferlist.rs @@ -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) } }