GNOME Bugzilla – Bug 785065
encodebin: fix possible pad ref leak in error code path
Last modified: 2017-07-25 08:49:57 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.
Please also provide patches together with bug reports like this. Thanks!
Created attachment 355912 [details] [review] Patch file is attached. Hello All, Please review the attached patch file and provide your feedback.
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