From dc1c9c898515f127741a6b4e203c5b13d5f9ce4c Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Fri, 10 Feb 2023 08:20:38 -0300 Subject: [PATCH] glvideomixer: Keep a reference to the underlying pad There was cases where we were accessing the pad while it was already destroyed. Ensure it can't happen by owning a ref on it. Part-of: --- .../gst-plugins-base/ext/gl/gstglvideomixer.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/subprojects/gst-plugins-base/ext/gl/gstglvideomixer.c b/subprojects/gst-plugins-base/ext/gl/gstglvideomixer.c index e3a589d368..10ed56e49a 100644 --- a/subprojects/gst-plugins-base/ext/gl/gstglvideomixer.c +++ b/subprojects/gst-plugins-base/ext/gl/gstglvideomixer.c @@ -234,6 +234,7 @@ static void gst_gl_video_mixer_input_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static gboolean gst_gl_video_mixer_src_event (GstAggregator * agg, GstEvent * event); +static void gst_gl_video_mixer_input_dispose (GObject * object); typedef struct _GstGLVideoMixerInput GstGLVideoMixerInput; typedef GstGhostPadClass GstGLVideoMixerInputClass; @@ -263,6 +264,7 @@ gst_gl_video_mixer_input_class_init (GstGLVideoMixerInputClass * klass) gobject_class->set_property = gst_gl_video_mixer_input_set_property; gobject_class->get_property = gst_gl_video_mixer_input_get_property; + gobject_class->dispose = gst_gl_video_mixer_input_dispose; g_object_class_install_property (gobject_class, PROP_INPUT_ZORDER, g_param_spec_uint ("zorder", "Z-Order", "Z Order of the picture", @@ -492,6 +494,14 @@ gst_gl_video_mixer_input_set_property (GObject * object, guint prop_id, g_object_set_property (G_OBJECT (self->mixer_pad), pspec->name, value); } +static void +gst_gl_video_mixer_input_dispose (GObject * object) +{ + GstGLVideoMixerInput *self = (GstGLVideoMixerInput *) object; + + gst_clear_object (&self->mixer_pad); +} + static GstGhostPad * _create_video_mixer_input (GstGLMixerBin * self, GstPad * mixer_pad) { @@ -525,7 +535,7 @@ _create_video_mixer_input (GstGLMixerBin * self, GstPad * mixer_pad) ADD_BINDING (mixer_pad, input, "yalign"); #undef ADD_BINDING - input->mixer_pad = mixer_pad; + input->mixer_pad = gst_object_ref (mixer_pad); return GST_GHOST_PAD (input); }