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 775071 - 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-good
1.10.1
Other Linux
: Normal normal
: 1.10.3
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-11-25 09:51 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() (918 bytes, patch)
2016-11-25 09:51 UTC, Garima
needs-work Details | Review
Fix Memory leak in gst_pad_get_current_caps() API usage (1.08 KB, patch)
2016-11-28 05:46 UTC, Garima
none Details | Review
Fixed memory leak in usage of gst_pad_get_current_caps() API (1.11 KB, patch)
2016-11-30 04:56 UTC, Garima
none Details | Review
Fixed memory leak in usage of gst_pad_get_current_caps() API (1.24 KB, patch)
2016-11-30 05:11 UTC, Garima
needs-work Details | Review
The final patch created with required changes (1.13 KB, patch)
2016-12-01 09:45 UTC, Garima
committed Details | Review

Description Garima 2016-11-25 09:51:44 UTC
Created attachment 340738 [details] [review]
memory leak in usage of gst_pad_get_current_caps()

In File: gst-plugins-good-1.10.1/gst/rtp/gstrtph264depay.c
Function: gst_rtp_h264_set_src_caps()
memory is allocated by old_caps at line:401 is not freed before the function returns.

In file: gst-plugins-good-1.10.1/gst/rtp/gstrtpsbcdepay.c
Function: gst_rtp_sbc_depay_setcaps()
memory is allocated by oldcaps at line:177 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:57:12 UTC
Review of attachment 340738 [details] [review]:

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

::: gst-plugins-good-1.10.1/gst/rtp/gstrtph264depay.c
@@ +441,2 @@
   gst_caps_unref (srccaps);
+  gst_caps_unref (old_caps);

old_caps might be NULL here. Unref them in the if above

::: gst-plugins-good-1.10.1/gst/rtp/gstrtpsbcdepay.c
@@ +183,2 @@
   gst_caps_unref (outcaps);
+  gst_caps_unref (oldcaps);

Same
Comment 2 Garima 2016-11-28 05:46:25 UTC
Created attachment 340872 [details] [review]
Fix Memory leak in gst_pad_get_current_caps() API usage

Fix Memory leak in gst_pad_get_current_caps() API usage.
This patch is in "git format-patch".
Comment 3 Sebastian Dröge (slomo) 2016-11-28 07:16:01 UTC
Review of attachment 340872 [details] [review]:

Please include the URL to the bug report as the last line of the commit message. Also still the same problems with the patch as before:

::: gst/rtp/gstrtph264depay.c
@@ +441,2 @@
   gst_caps_unref (srccaps);
+  gst_caps_unref (old_caps);

Here you are unreffing NULL caps. Move the unref into the "if (old_caps != NULL)" branch above.

::: gst/rtp/gstrtpsbcdepay.c
@@ +183,2 @@
   gst_caps_unref (outcaps);
+  gst_caps_unref (oldcaps);

Same
Comment 4 Garima 2016-11-30 04:56:57 UTC
Created attachment 341019 [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 Garima 2016-11-30 05:06:18 UTC
(In reply to Garima from comment #4)
> Created attachment 341019 [details] [review] [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.

This patch has some error. I will add other patch soon.
Comment 6 Garima 2016-11-30 05:11:21 UTC
Created attachment 341020 [details] [review]
Fixed memory leak in usage of gst_pad_get_current_caps() API

Final changes
Please review the patch.
Comment 7 Sebastian Dröge (slomo) 2016-11-30 08:03:24 UTC
Review of attachment 341020 [details] [review]:

::: gst/rtp/gstrtpsbcdepay.c
@@ +179,3 @@
     /* Caps have changed, flush old data */
     gst_adapter_clear (depay->adapter);
+    gst_caps_unref (oldcaps);

You leak oldcaps if they are not NULL but can intersect with caps. Just put a "if (oldcaps) gst_caps_unref (oldcaps)" after the whole if
Comment 8 Garima 2016-12-01 09:45:14 UTC
Created attachment 341128 [details] [review]
The final patch created with required changes

The final patch created with required changes.
Comment 9 Sebastian Dröge (slomo) 2016-12-01 11:04:55 UTC
commit 50e7096a86ea120ca4b5b42294a8d80433803cc6
Author: Garima Gaur <garima.g@samsung.com>
Date:   Thu Dec 1 15:06:06 2016 +0530

    rtp: Fix some memory leaks in usage of gst_pad_get_current_caps()
    
    https://bugzilla.gnome.org/show_bug.cgi?id=775071