From 3a20c0bca3175322627b781c582a89e39abdaaa0 Mon Sep 17 00:00:00 2001 From: Doug Nazar Date: Fri, 14 Mar 2025 22:09:21 -0400 Subject: [PATCH] gl: Free various props during cleanup Part-of: --- .../gst-plugins-base/ext/gl/gstglbumper.c | 12 ++++++++++++ .../ext/gl/gstgldifferencematte.c | 18 ++++++++++++++++-- .../gst-plugins-base/ext/gl/gstgloverlay.c | 12 ++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-base/ext/gl/gstglbumper.c b/subprojects/gst-plugins-base/ext/gl/gstglbumper.c index 56152a6937..2888c81167 100644 --- a/subprojects/gst-plugins-base/ext/gl/gstglbumper.c +++ b/subprojects/gst-plugins-base/ext/gl/gstglbumper.c @@ -65,6 +65,7 @@ G_DEFINE_TYPE_WITH_CODE (GstGLBumper, gst_gl_bumper, GST_TYPE_GL_FILTER, GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (glbumper, "glbumper", GST_RANK_NONE, GST_TYPE_GL_BUMPER, gl_element_init (plugin)); +static void gst_gl_bumper_finalize (GObject * object); static void gst_gl_bumper_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void gst_gl_bumper_get_property (GObject * object, guint prop_id, @@ -281,6 +282,7 @@ gst_gl_bumper_class_init (GstGLBumperClass * klass) gobject_class = (GObjectClass *) klass; element_class = GST_ELEMENT_CLASS (klass); + gobject_class->finalize = gst_gl_bumper_finalize; gobject_class->set_property = gst_gl_bumper_set_property; gobject_class->get_property = gst_gl_bumper_get_property; @@ -316,6 +318,16 @@ gst_gl_bumper_init (GstGLBumper * bumper) bumper->location = NULL; } +static void +gst_gl_bumper_finalize (GObject * object) +{ + GstGLBumper *bumper = GST_GL_BUMPER (object); + + g_free (bumper->location); + + G_OBJECT_CLASS (parent_class)->finalize (object); +} + static void gst_gl_bumper_reset (GstGLFilter * filter) { diff --git a/subprojects/gst-plugins-base/ext/gl/gstgldifferencematte.c b/subprojects/gst-plugins-base/ext/gl/gstgldifferencematte.c index ff376ec109..6dfa56ce78 100644 --- a/subprojects/gst-plugins-base/ext/gl/gstgldifferencematte.c +++ b/subprojects/gst-plugins-base/ext/gl/gstgldifferencematte.c @@ -62,6 +62,7 @@ G_DEFINE_TYPE_WITH_CODE (GstGLDifferenceMatte, gst_gl_differencematte, GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (gldifferencematte, "gldifferencematte", GST_RANK_NONE, GST_TYPE_GL_DIFFERENCEMATTE, gl_element_init (plugin)); +static void gst_gl_differencematte_finalize (GObject * object); static void gst_gl_differencematte_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void gst_gl_differencematte_get_property (GObject * object, @@ -215,8 +216,10 @@ gst_gl_differencematte_gl_stop (GstGLBaseFilter * base_filter) differencematte->midtexture[i] = NULL; } } - differencematte->location = NULL; - differencematte->pixbuf = NULL; + if (differencematte->pixbuf) { + free (differencematte->pixbuf); + differencematte->pixbuf = NULL; + } differencematte->bg_has_changed = FALSE; GST_GL_BASE_FILTER_CLASS (parent_class)->gl_stop (base_filter); @@ -233,6 +236,7 @@ gst_gl_differencematte_class_init (GstGLDifferenceMatteClass * klass) gst_gl_filter_add_rgba_pad_templates (GST_GL_FILTER_CLASS (klass)); + gobject_class->finalize = gst_gl_differencematte_finalize; gobject_class->set_property = gst_gl_differencematte_set_property; gobject_class->get_property = gst_gl_differencematte_get_property; @@ -274,6 +278,16 @@ gst_gl_differencematte_init (GstGLDifferenceMatte * differencematte) fill_gaussian_kernel (differencematte->kernel, 7, 30.0); } +static void +gst_gl_differencematte_finalize (GObject * object) +{ + GstGLDifferenceMatte *differencematte = GST_GL_DIFFERENCEMATTE (object); + + g_free (differencematte->location); + + G_OBJECT_CLASS (parent_class)->finalize (object); +} + static void gst_gl_differencematte_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) diff --git a/subprojects/gst-plugins-base/ext/gl/gstgloverlay.c b/subprojects/gst-plugins-base/ext/gl/gstgloverlay.c index 9336791de2..667039eaf7 100644 --- a/subprojects/gst-plugins-base/ext/gl/gstgloverlay.c +++ b/subprojects/gst-plugins-base/ext/gl/gstgloverlay.c @@ -72,6 +72,7 @@ GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (gloverlay, "gloverlay", static gboolean gst_gl_overlay_set_caps (GstGLFilter * filter, GstCaps * incaps, GstCaps * outcaps); +static void gst_gl_overlay_finalize (GObject * object); static void gst_gl_overlay_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void gst_gl_overlay_get_property (GObject * object, guint prop_id, @@ -203,6 +204,7 @@ gst_gl_overlay_class_init (GstGLOverlayClass * klass) gst_gl_filter_add_rgba_pad_templates (GST_GL_FILTER_CLASS (klass)); + gobject_class->finalize = gst_gl_overlay_finalize; gobject_class->set_property = gst_gl_overlay_set_property; gobject_class->get_property = gst_gl_overlay_get_property; @@ -288,6 +290,16 @@ gst_gl_overlay_init (GstGLOverlay * overlay) overlay->alpha = 1.0; } +static void +gst_gl_overlay_finalize (GObject * object) +{ + GstGLOverlay *overlay = GST_GL_OVERLAY (object); + + g_free (overlay->location); + + G_OBJECT_CLASS (parent_class)->finalize (object); +} + static void gst_gl_overlay_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec)