gstreamer: Add debug assertions to ensure &mut StructureRef is only created from mutable structures

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1743>
This commit is contained in:
Sebastian Dröge 2025-06-26 18:43:01 +03:00
parent 7daf6d9625
commit 428617f87a

View file

@ -483,6 +483,8 @@ impl StructureRef {
#[inline]
pub unsafe fn from_glib_borrow_mut<'a>(ptr: *mut ffi::GstStructure) -> &'a mut StructureRef {
debug_assert!(!ptr.is_null());
#[cfg(feature = "v1_28")]
debug_assert_ne!(ffi::gst_structure_is_writable(ptr), glib::ffi::GFALSE,);
&mut *(ptr as *mut StructureRef)
}