From 631eee13da3322bb1d6d254c09e9e8a8941f093e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 1 Mar 2019 19:49:27 +0200 Subject: [PATCH] gstreamer/pad: Use the correct type for destroying the pad task closure data It's a Box> and not a plain Box<_> like for the other pad functions, and doing this wrong causes crashes at runtime. --- gstreamer/src/pad.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gstreamer/src/pad.rs b/gstreamer/src/pad.rs index 418c61657..8bafa099d 100644 --- a/gstreamer/src/pad.rs +++ b/gstreamer/src/pad.rs @@ -704,7 +704,7 @@ impl> PadExtManual for O { self.as_ref().to_glib_none().0, Some(trampoline_pad_task::), into_raw_pad_task(func), - Some(destroy_closure::), + Some(destroy_closure_pad_task::), ), "Failed to start pad task", ) @@ -1351,6 +1351,10 @@ fn into_raw_pad_task(func: F) -> gpointer { Box::into_raw(func) as gpointer } +unsafe extern "C" fn destroy_closure_pad_task(ptr: gpointer) { + Box::>::from_raw(ptr as *mut _); +} + #[cfg(test)] mod tests { use super::*;