After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 333512 - [PATCH] Fix gst_pad_new_from_template (gst_static_pad_template_get ()) leaks
[PATCH] Fix gst_pad_new_from_template (gst_static_pad_template_get ()) leaks
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
git master
Other Linux
: Normal normal
: 0.10.3
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2006-03-05 18:02 UTC by Christophe Fergeau
Modified: 2006-03-15 16:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix described leaks (except in the oldcore/ directory) (51.68 KB, patch)
2006-03-05 18:02 UTC, Christophe Fergeau
none Details | Review

Description Christophe Fergeau 2006-03-05 18:02:10 UTC
+++ This bug was initially created as a clone of Bug #333510 +++

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.
Comment 1 Christophe Fergeau 2006-03-05 18:02:52 UTC
Created attachment 60702 [details] [review]
Fix described leaks (except in the oldcore/ directory)
Comment 2 Edward Hervey 2006-03-15 16:18:42 UTC
I made a similar patch, but using gst_pad_new_from_static_template() instead since it's less verbose.

2006-03-15  Edward Hervey  <edward@fluendo.com>

	* ext/cairo/gsttextoverlay.c: (gst_text_overlay_init):
	* ext/dv/gstdvdemux.c: (gst_dvdemux_init), (gst_dvdemux_add_pads):
	* ext/gdk_pixbuf/gstgdkpixbuf.c: (gst_gdk_pixbuf_init):
	* ext/jpeg/gstjpegdec.c: (gst_jpeg_dec_init),
	(gst_jpeg_dec_setcaps):
	* ext/jpeg/gstjpegenc.c: (gst_jpegenc_init):
	* ext/jpeg/gstsmokedec.c: (gst_smokedec_init):
	* ext/jpeg/gstsmokeenc.c: (gst_smokeenc_init):
	* ext/libmng/gstmngdec.c: (gst_mngdec_init),
	(gst_mngdec_src_getcaps):
	* ext/libpng/gstpngdec.c: (gst_pngdec_init),
	(gst_pngdec_caps_create_and_set):
	* ext/libpng/gstpngenc.c: (gst_pngenc_init):
	* ext/mikmod/gstmikmod.c: (gst_mikmod_init):
	* ext/speex/gstspeexdec.c: (gst_speex_dec_init):
	* gst/alpha/gstalpha.c: (gst_alpha_init):
	* gst/auparse/gstauparse.c: (gst_au_parse_init):
	* gst/avi/gstavidemux.c: (gst_avi_demux_init),
	(gst_avi_demux_handle_src_event), (gst_avi_demux_parse_stream):
	* gst/cutter/gstcutter.c: (gst_cutter_init):
	* gst/debug/efence.c: (gst_efence_init), (gst_efence_getrange),
	(gst_efence_checkgetrange):
	* gst/debug/negotiation.c: (gst_negotiation_init):
	* gst/flx/gstflxdec.c: (gst_flxdec_init):
	* gst/goom/gstgoom.c: (gst_goom_init):
	* gst/rtp/gstasteriskh263.c: (gst_asteriskh263_init):
	* gst/rtp/gstrtpL16depay.c: (gst_rtp_L16depay_init):
	* gst/rtp/gstrtpL16pay.c: (gst_rtpL16pay_init):
	* gst/rtp/gstrtpamrdepay.c: (gst_rtp_amr_depay_init):
	* gst/rtp/gstrtpdepay.c: (gst_rtp_depay_init):
	* gst/rtp/gstrtpmpadepay.c: (gst_rtp_mpa_depay_init):
	* gst/rtsp/gstrtpdec.c: (gst_rtpdec_init):
	* gst/smpte/gstsmpte.c: (gst_smpte_init):
	* gst/wavparse/gstwavparse.c: (gst_wavparse_init),
	(gst_wavparse_create_sourcepad):
	Fix memleak with gst_static_pad_template_get().
	This uses gst_pad_new_from_static_template() instead.
	Fixes #333512

Comment 3 Christophe Fergeau 2006-03-15 16:20:33 UTC
Great, thanks :) (I didn't know about gst_pad_new_from_static_template when I wrote that patch :-/ )