From af5470a8b0802eec96e093c53b01c442611cc1cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 24 Jul 2018 15:35:26 +0300 Subject: [PATCH] Unref the message in sync bus handlers if Drop is returned --- gstreamer/src/bus.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gstreamer/src/bus.rs b/gstreamer/src/bus.rs index b9ce803d2..bf70d005b 100644 --- a/gstreamer/src/bus.rs +++ b/gstreamer/src/bus.rs @@ -50,7 +50,13 @@ unsafe extern "C" fn trampoline_sync( ) -> ffi::GstBusSyncReply { #[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))] let f: &&(Fn(&Bus, &Message) -> BusSyncReply + Send + Sync + 'static) = transmute(func); - f(&from_glib_borrow(bus), &Message::from_glib_borrow(msg)).to_glib() + let res = f(&from_glib_borrow(bus), &Message::from_glib_borrow(msg)).to_glib(); + + if res == ffi::GST_BUS_DROP { + ffi::gst_mini_object_unref(msg as *mut _); + } + + res } unsafe extern "C" fn destroy_closure_sync(ptr: gpointer) {