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 753851 - gstreamer: Fix memory leaks when context parse fails.
gstreamer: Fix memory leaks when context parse fails.
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other Linux
: Normal normal
: 1.7.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-08-20 00:42 UTC by Vineeth
Modified: 2015-10-02 14:31 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gstreamer:tools: fix memory leaks during context parse failures. (4.17 KB, patch)
2015-08-20 00:44 UTC, Vineeth
none Details | Review
gstreamer:tests: fix memory leaks during context parse failures. (2.43 KB, patch)
2015-08-20 00:54 UTC, Vineeth
none Details | Review
gstreamer:libs: fix memory leaks during context parse failures. (5.77 KB, patch)
2015-08-20 01:02 UTC, Vineeth
none Details | Review
gstreamer:libs: fix memory leaks during context parse failures. (5.77 KB, patch)
2015-08-20 01:03 UTC, Vineeth
none Details | Review
gstreamer:libs: fix memory leaks during context parse failures. (5.77 KB, patch)
2015-08-20 01:05 UTC, Vineeth
none Details | Review
gstreamer: fix memory leaks during context parse failures. (13.96 KB, patch)
2015-08-20 07:45 UTC, Vineeth
committed Details | Review

Description Vineeth 2015-08-20 00:42:43 UTC
In all places where g_option_context_parse is being used, when it fails, the context and error variables are not getting freed, which will result in memory leaks.
Along with that replacing g_error_free with g_clear_error in these files, which is a better way to free error, as it checks if the variable is Non-NULL and then sets it to NULL on freeing.

Making it into 3 patches for better readability, based on folders of the files.(tools, tests, libs).. If needed all these can be squashed into a single patch.
Comment 1 Vineeth 2015-08-20 00:44:24 UTC
Created attachment 309654 [details] [review]
gstreamer:tools: fix memory leaks during context parse failures.

patch 1 for tools folder
Comment 2 Vineeth 2015-08-20 00:54:25 UTC
Created attachment 309655 [details] [review]
gstreamer:tests: fix memory leaks during context parse failures.

patch 2: tests folder
Comment 3 Vineeth 2015-08-20 01:02:35 UTC
Created attachment 309656 [details] [review]
gstreamer:libs: fix memory leaks during context parse failures.

patch 3: libs folder
Comment 4 Vineeth 2015-08-20 01:03:54 UTC
Created attachment 309657 [details] [review]
gstreamer:libs: fix memory leaks during context parse failures.

patch 3: libs folder
Comment 5 Vineeth 2015-08-20 01:05:40 UTC
Created attachment 309658 [details] [review]
gstreamer:libs: fix memory leaks during context parse failures.

libs patch got added twice by mistake.
Comment 6 Vineeth 2015-08-20 01:09:37 UTC
Should probably change in docs as well i guess right?
html and xml files.
Comment 7 Sebastian Dröge (slomo) 2015-08-20 06:50:02 UTC
Thanks, but please squash all the commits into one
Comment 8 Sebastian Dröge (slomo) 2015-08-20 06:58:49 UTC
Comment on attachment 309658 [details] [review]
gstreamer:libs: fix memory leaks during context parse failures.

No change needed here other than squashing, but note that g_error() will exit the application so the g_clear_error() after g_error() are useless... still good to have them for consistency.
Comment 9 Vineeth 2015-08-20 07:13:19 UTC
should i change for the docs as well in this patch? I saw few html and xml files also needs changing
Comment 10 Sebastian Dröge (slomo) 2015-08-20 07:14:18 UTC
Yes please, also for the other patches if needed.
Comment 11 Vineeth 2015-08-20 07:45:11 UTC
Created attachment 309680 [details] [review]
gstreamer: fix memory leaks during context parse failures.

squashed all the patches and added the changes to docs, *.xml files
Comment 12 Sebastian Dröge (slomo) 2015-10-02 14:31:36 UTC
commit 215cfcf993389c7950d58d7a37d9bfb0058b7ea6
Author: Vineeth TM <vineeth.tm@samsung.com>
Date:   Thu Aug 20 16:21:59 2015 +0900

    gstreamer: Fix memory leaks when context parse fails
    
    When g_option_context_parse fails, context and error variables are not getting free'd
    which results in memory leaks. Free'ing the same.
    
    And replacing g_error_free with g_clear_error, which checks if the error being passed
    is not NULL and sets the variable to NULL on free'ing.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=753851