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 775072 - memory leak in usage of gst_pad_get_current_caps() API
memory leak in usage of gst_pad_get_current_caps() API
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
1.10.1
Other Linux
: Normal normal
: 1.10.3
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-11-25 10:01 UTC by Garima
Modified: 2016-12-05 09:15 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
memory leak in usage of gst_pad_get_current_caps() API (964 bytes, patch)
2016-11-25 10:01 UTC, Garima
needs-work Details | Review
Fix Memory leak in gst_pad_get_current_caps() API usage (1.16 KB, patch)
2016-11-28 05:56 UTC, Garima
none Details | Review
Fixed memory leak in usage of gst_pad_get_current_caps() API (1.36 KB, patch)
2016-11-30 05:17 UTC, Garima
committed Details | Review

Description Garima 2016-11-25 10:01:40 UTC
Created attachment 340741 [details] [review]
memory leak in usage of gst_pad_get_current_caps() API

File:gst-plugins-bad-1.10.1/gst/mpegpsmux/mpegpsmux.c
Function: mpegpsmux_create_stream()
memory allocated to 'caps' at line:225 is not freed before the function returns.

File:gst-plugins-bad-1.10.1/tests/examples/directfb/gstdfb.c
Function: size_changed()
memory allocated to 'caps' at line:86 is not freed before the function returns.

Applied Fix: Added gst_caps_unref to free the allocated memory.
Comment 1 Sebastian Dröge (slomo) 2016-11-25 10:58:30 UTC
Review of attachment 340741 [details] [review]:

Please provide patches in "git format-patch" format with a meaningful commit message, thanks!

::: gst-plugins-bad-1.10.1/gst/mpegpsmux/mpegpsmux.c
@@ +231,3 @@
   s = gst_caps_get_structure (caps, 0);
+
+  gst_caps_unref (caps);  

This will invalidate "s", which is still used afterwards. You can only unref after "s" is not used anymore

::: gst-plugins-bad-1.10.1/tests/examples/directfb/gstdfb.c
@@ +89,3 @@
   s = gst_caps_get_structure (caps, 0);
+ 
+  gst_caps_unref (caps);  

same
Comment 2 Garima 2016-11-28 05:56:38 UTC
Created attachment 340874 [details] [review]
Fix Memory leak in gst_pad_get_current_caps() API usage

Added patch is in "git format-patch".
Comment 3 Sebastian Dröge (slomo) 2016-11-28 07:17:58 UTC
Review of attachment 340874 [details] [review]:

Please put the URL to the bug report as last line in the commit message. And the patch still has the same problems as before:

::: gst/mpegpsmux/mpegpsmux.c
@@ +231,2 @@
   s = gst_caps_get_structure (caps, 0);
+  gst_caps_unref (caps);

"s" becomes invalid by unreffing the caps that own it. Only unref the caps after all usage of the GstStructure is done.

::: tests/examples/directfb/gstdfb.c
@@ +89,2 @@
   s = gst_caps_get_structure (caps, 0);
+  gst_caps_unref (caps);

Same
Comment 4 Garima 2016-11-30 05:17:43 UTC
Created attachment 341021 [details] [review]
Fixed memory leak in usage of gst_pad_get_current_caps() API

Now I have added the patch as per the requirement.
Please review the patch with all required changes.
Comment 5 Sebastian Dröge (slomo) 2016-11-30 07:59:55 UTC
commit aa08be43c7348dc1e0f6e968946bd810c417c267
Author: Garima Gaur <garima.g@samsung.com>
Date:   Wed Nov 30 10:40:42 2016 +0530

    gst: Fix caps leak
    
    https://bugzilla.gnome.org/show_bug.cgi?id=775072