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 785065 - encodebin: fix possible pad ref leak in error code path
encodebin: fix possible pad ref leak in error code path
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
1.12.2
Other All
: Normal minor
: 1.12.3
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-07-18 14:01 UTC by Satya Prakash Gupta
Modified: 2017-07-25 08:49 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch file is attached. (719 bytes, patch)
2017-07-19 03:42 UTC, Satya Prakash Gupta
committed Details | Review

Description Satya Prakash Gupta 2017-07-18 14:01:12 UTC
Hello All,

There is possible Memory leak in gstencodebin.c

File  : gst-plugins-base/gst/encoding/gstencodebin.c

In function "_create_stream_group" at line: 1258

here srcpad are allocated .

srcpad = gst_element_get_static_pad (sgroup->outqueue, "src");
In case of failure of muxerpad .. it did not unref.. So It might cause possible memory leak issue.

if (muxerpad) {
    if (G_UNLIKELY (fast_pad_link (srcpad, muxerpad) != GST_PAD_LINK_OK)) {
      goto muxer_link_failure;
    }
    gst_object_unref (muxerpad);
  } else {
    gst_ghost_pad_set_target (GST_GHOST_PAD (ebin->srcpad), srcpad);
  }

Also Same is observed at line 1411.

srcpad must be unref after used.
 
below documentation also suggest :
https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstElement.html#gst-element-get-static-pad


Solution: There must be   gst_object_unref (srcpad);

Please check and provide your feedback.
Comment 1 Sebastian Dröge (slomo) 2017-07-18 14:51:29 UTC
Please also provide patches together with bug reports like this. Thanks!
Comment 2 Satya Prakash Gupta 2017-07-19 03:42:51 UTC
Created attachment 355912 [details] [review]
Patch file is attached.

Hello All,

Please review the attached patch file and provide your feedback.
Comment 3 Tim-Philipp Müller 2017-07-19 08:10:28 UTC
Thanks for the patch, but it's not quite complete.

There's a compiler warning about how srcpad might be used uninitialized, and we should also reset srcpad to NULL when we do properly unref it in the code, so that we don't accidentally unref it twice when we hit an error.

I've fixed it up a bit and pushed it:

commit 3cc824c9cef76c93c3318f3691f8a51ba7c8f9c3
Author: Satya Prakash Gupta <sp.gupta@samsung.com>
Date:   Wed Jul 19 09:02:26 2017 +0530

    encodebin: fix possible pad ref leak in error code path
    
    https://bugzilla.gnome.org/show_bug.cgi?id=785065