GNOME Bugzilla – Bug 333510
[PATCH] Fix gst_pad_new_from_template (gst_static_pad_template_get ()) leaks
Last modified: 2006-03-09 15:06:30 UTC
Many elements use something like: overlay->video_sinkpad = gst_pad_new_from_template (gst_static_pad_template_get (&video_sink_template_factory), "video_sink"); in their _init function. This is wrong since gst_pad_new_from_template creates a copy of its parameter: static void gst_pad_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { [...] case PAD_PROP_TEMPLATE: gst_pad_set_pad_template (GST_PAD_CAST (object), (GstPadTemplate *) g_value_dup_gst_object (value)); break; } GstPad * gst_pad_new_from_template (GstPadTemplate * templ, const gchar * name) { g_return_val_if_fail (GST_IS_PAD_TEMPLATE (templ), NULL); return g_object_new (GST_TYPE_PAD, "name", name, "direction", templ->direction, "template", templ, NULL); } gst_object_unref needs to be ran on the result of gst_static_pad_template_get to avoid leaking this GstPadTemplate.
Created attachment 60701 [details] [review] Fix leaks
* ext/pango/gsttextoverlay.c: (gst_text_overlay_init): * ext/pango/gsttextrender.c: (gst_text_render_init): * gst/adder/gstadder.c: (gst_adder_init): Don't leak padtemplates, patch by Christophe Fergeau, closes #333510.