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 772497 - waveform : Fix Memory leak by gst_caps_to_string
waveform : Fix Memory leak by gst_caps_to_string
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
git master
Other Linux
: Normal minor
: 1.10.0
Assigned To: GStreamer Maintainers
GStreamer Maintainers
: 773306 (view as bug list)
Depends on:
Reported: 2016-10-06 06:13 UTC by Gaurav
Modified: 2016-10-31 14:34 UTC
See Also:
GNOME target: ---
GNOME version: ---

waveform : Fix Memory leak by gst_caps_to_string (1.08 KB, patch)
2016-10-06 06:13 UTC, Gaurav
none Details | Review
Fix memory leak by gst_caps_to_string() using GST_PTR_FORMAT (852 bytes, patch)
2016-10-07 07:40 UTC, Gaurav
committed Details | Review

Description Gaurav 2016-10-06 06:13:35 UTC
Created attachment 337038 [details] [review]
waveform : Fix Memory leak by gst_caps_to_string

gst_caps_to_string() returned allocated memory, which must be freed using g_free(). The current patch fixes the memory leak due to call of gst_caps_to_string().
Please review.
Comment 1 Sebastian Dröge (slomo) 2016-10-06 10:26:08 UTC
Review of attachment 337038 [details] [review]:

::: sys/waveform/gstwaveformsink.c
@@ +327,3 @@
   GST_CAT_LOG_OBJECT (waveformsink_debug, wfsink, "Returning caps %s",
+      caps_str);
+  g_free (caps_str);

Use GST_PTR_FORMAT here instead of manually converting to string & freeing
Comment 2 Gaurav 2016-10-06 10:30:13 UTC
SO, you mean using GST_PTR_FORMAT is better way as it avoid memory allocation also ?
So, is it the best way wherever gst_caps_to_string() is used for logging/error reporting purposes?
Comment 3 Sebastian Dröge (slomo) 2016-10-06 10:34:48 UTC
It does not avoid the allocation, it just avoids additional code. It also only works in the GST_DEBUG (etc) macros. Do
> GST_CAT_LOG_OBJECT (......, "bla %" GST_PTR_FORMAT, caps)
Comment 4 Gaurav 2016-10-06 10:40:42 UTC
Ok, I will send updated patch.
Comment 5 Gaurav 2016-10-06 11:23:16 UTC
Shaill I change other instances also where gst_caps_to_string() is used for logging/error reporting?
Comment 6 Gaurav 2016-10-07 07:40:59 UTC
Created attachment 337135 [details] [review]
Fix memory leak by gst_caps_to_string() using GST_PTR_FORMAT

Use GST_PTR_FORMAT instead of gst_caps_to_string() API for simplicity.
Comment 7 Sebastian Dröge (slomo) 2016-10-20 10:14:28 UTC
commit 1950b72e2b6a9b4d2dc6799c0694ab1f5b0c1ef6
Author: Gaurav Gupta <>
Date:   Fri Oct 7 13:04:27 2016 +0530

    waveformsink: Fix Memory leak using GST_PTR_FORMAT
Comment 8 Sebastian Dröge (slomo) 2016-10-20 10:15:47 UTC
Review of attachment 337135 [details] [review]:

::: sys/waveform/gstwaveformsink.c
@@ +323,3 @@
+  GST_CAT_LOG_OBJECT (waveformsink_debug, wfsink, "Returning caps %s" GST_PTR_FORMAT, caps);

That's not how this works, but I fixed that up before merging.

It's  "... %" GST_PTR_FORMAT, caps) without the s
Comment 9 Sebastian Dröge (slomo) 2016-10-21 11:43:41 UTC
*** Bug 773306 has been marked as a duplicate of this bug. ***