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 784978 - omx: Possible Memory leak in gst_caps_from_string
omx: Possible Memory leak in gst_caps_from_string
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-omx
1.12.2
Other Windows
: Normal minor
: 1.12.3
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-07-15 11:31 UTC by Satya Prakash Gupta
Modified: 2017-07-25 08:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch is attched (693 bytes, patch)
2017-07-17 13:09 UTC, Satya Prakash Gupta
needs-work Details | Review
Patch file is attached. (986 bytes, patch)
2017-07-17 13:37 UTC, Satya Prakash Gupta
committed Details | Review

Description Satya Prakash Gupta 2017-07-15 11:31:42 UTC
Hello All,

There is possible Memory leak in gstomx.c

File  : gst-omx/omx/gstmox.c

In function "_class_init" at line: 2662

here caps are allocated .
caps = gst_caps_from_string (template_caps);

In function gst_pad_template_new(...) at Line  :2636 and 2662 

caps must be unref after used.
 
below documentation also suggest :
https://sourcecodebrowser.com/gstreamer0.10/0.10.18/gst_2gstcaps_8c.html#a90f2094f46fc946b6850dd606558f81f


Solution: There must be  gst_caps_unref(caps); after use of caps.

Please check and provide your feedback.
Comment 1 Nicolas Dufresne (ndufresne) 2017-07-15 16:18:07 UTC
This is correct, though, this is just a leak ref, the caps in caps template are never freed, that is normal. Will you provide a patch ? Be aware of the following section, using the same pattern hence leaving the caps to ref 2 instead of ref 1.
Comment 2 Satya Prakash Gupta 2017-07-17 13:09:09 UTC
Created attachment 355746 [details] [review]
Patch is attched

Hello All,

Please review the attached patch and provide your feedback.
Comment 3 Sebastian Dröge (slomo) 2017-07-17 13:27:47 UTC
Review of attachment 355746 [details] [review]:

::: omx/gstomx.c
@@ +2663,3 @@
     g_free (template_caps);
     gst_element_class_add_pad_template (element_class, templ);
+    gst_caps_unref (caps);

There's the same leak for the sink pad template a few lines above
Comment 4 Satya Prakash Gupta 2017-07-17 13:37:11 UTC
Created attachment 355750 [details] [review]
Patch file is attached.
Comment 5 Sebastian Dröge (slomo) 2017-07-17 13:46:58 UTC
commit 5e6c3f170f3513dff3eb7384ed211a88c85b51f8 (HEAD -> master)
Author: Satya Prakash Gupta <sp.gupta@samsung.com>
Date:   Mon Jul 17 18:36:36 2017 +0530

    omx: Possible Memory leak in gst_caps_from_string
    
    https://bugzilla.gnome.org/show_bug.cgi?id=784978