From aeb262a7e1bc2c0da7e63e48f568d5bebc6c77fb Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Thu, 9 Feb 2023 13:53:48 +0100 Subject: [PATCH] pad: Don't leak user_data in gst_pad_start_task When the task already exists, we forgot to free the passed `user_data`. This wasn't an issue for most C code, which doesn't pass a `GDestroyNotify`, but bindings such as gstreamer-rs do! That said, allocating a trampoline in gstreamer-rs just for it to get thrown away again is awkward. Maybe we need a `gst_pad_resume_task`? Part-of: --- subprojects/gstreamer/gst/gstpad.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/subprojects/gstreamer/gst/gstpad.c b/subprojects/gstreamer/gst/gstpad.c index db9893352a..caf9b36eb2 100644 --- a/subprojects/gstreamer/gst/gstpad.c +++ b/subprojects/gstreamer/gst/gstpad.c @@ -6324,6 +6324,7 @@ gst_pad_start_task (GstPad * pad, GstTaskFunction func, gpointer user_data, task = GST_PAD_TASK (pad); if (task == NULL) { task = gst_task_new (func, user_data, notify); + notify = NULL; gst_task_set_lock (task, GST_PAD_GET_STREAM_LOCK (pad)); gst_task_set_enter_callback (task, pad_enter_thread, pad, NULL); gst_task_set_leave_callback (task, pad_leave_thread, pad, NULL); @@ -6345,6 +6346,10 @@ gst_pad_start_task (GstPad * pad, GstTaskFunction func, gpointer user_data, res = gst_task_set_state (task, GST_TASK_STARTED); GST_OBJECT_UNLOCK (pad); + /* free user_data if it wasn't used for gst_task_new */ + if (notify) + notify (user_data); + return res; /* ERRORS */