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 784982 - x264enc, mpg123audiodec: possible template caps leak
x264enc, mpg123audiodec: possible template caps leak
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-ugly
1.12.2
Other All
: Normal minor
: 1.12.3
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-07-15 13:36 UTC by Satya Prakash Gupta
Modified: 2017-07-25 08:50 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Satya Prakash Gupta 2017-07-15 13:36:21 UTC
Hello All,

There is possible memory leak in 

File  : gst-plugins-ugly/ext/mpg123/gstmpg123audiodec.c

In function "gst_mpg123_audio_dec_class_init" at line: 167
gstcaps is assigned as per below 
 "src_template_caps = gst_caps_from_string (s->str)"

 but src_template_caps is not unref ..
 
It must be unref as below documentation :
https://sourcecodebrowser.com/gstreamer0.10/0.10.18/gst_2gstcaps_8c.html#a90f2094f46fc946b6850dd606558f81f


Also It is valid for :
File : gst-plugins-ugly/ext/x264/gstx264enc.c

In function "gst_x264_enc_class_init" at line : 1137

"supported_sinkcaps" should be unref.

It must be unref as below documentation :
https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstCaps.html#gst-caps-new-simple
" Caller is responsible for unreffing the returned caps."


Solution: There should be  gst_caps_unref(src_template_caps); and also  gst_caps_unref(supported_sinkcaps) after use of caps.

Please check and provide your feedback about it.
Comment 1 Tim-Philipp Müller 2017-07-15 14:03:34 UTC
Thanks, fixed:

commit 58a23c99e932eb4a221673a118d1675fdabd58e2
Author: Tim-Philipp Müller <tim@centricular.com>
Date:   Sat Jul 15 14:59:42 2017 +0100

    x264enc: fix caps leak
    
    Move creation of supported sink pads into class_init function
    which is also the only place where they're used. Unref the
    caps when no longer needed, the pad template will take its
    own ref.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=784982

commit 841a073154d9ab512b2abba997552b2ae354bc92
Author: Tim-Philipp Müller <tim@centricular.com>
Date:   Sat Jul 15 14:57:49 2017 +0100

    mpg123audiodec: fix caps leak
    
    The pad template takes its own ref, so we should unref the caps.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=784982


This is not really a problem in practice though since plugins/classes won't get unloaded after they're created, so it's just for cleanliness really.