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 783418 - audioconvert: Fix memory leak in test code failure path
audioconvert: Fix memory leak in test code failure path
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other Linux
: Normal enhancement
: 1.13.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-06-05 05:28 UTC by Jimmy Ohn
Modified: 2018-01-19 18:52 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix memory leak in test code (1.76 KB, patch)
2017-06-05 05:29 UTC, Jimmy Ohn
none Details | Review
Fix memory leak in test code (1.77 KB, patch)
2017-06-05 06:46 UTC, Jimmy Ohn
none Details | Review
Fix memory leak in test code (1.85 KB, patch)
2017-06-05 10:21 UTC, Jimmy Ohn
none Details | Review
Fix memory leak in test code (1.82 KB, patch)
2017-06-05 11:44 UTC, Jimmy Ohn
none Details | Review
Fix memory leak in test code (1.82 KB, patch)
2017-06-05 11:48 UTC, Jimmy Ohn
none Details | Review

Description Jimmy Ohn 2017-06-05 05:28:44 UTC
As I know, gst_structure_to_string function returned allocated memory.
So, It should be free using g_free function.
Comment 1 Jimmy Ohn 2017-06-05 05:29:46 UTC
Created attachment 353163 [details] [review]
Fix memory leak in test code
Comment 2 Jimmy Ohn 2017-06-05 06:46:26 UTC
Created attachment 353167 [details] [review]
Fix memory leak in test code
Comment 3 Tim-Philipp Müller 2017-06-05 09:16:02 UTC
In the error/failure case everything else will be leaked as well, since g_error() aborts.

If you found this with a static code analzyer you should probably tell it that g_error() never returns.
Comment 4 Jimmy Ohn 2017-06-05 10:21:21 UTC
thanks for your comment. that's my mistake.
I didn't use static code analyzer. I just use grep command for "FIXME" or "TODO".
As you mentioned g_error(), I modify GST_DEBUG instead it.
Comment 5 Jimmy Ohn 2017-06-05 10:21:47 UTC
Created attachment 353174 [details] [review]
Fix memory leak in test code
Comment 6 Tim-Philipp Müller 2017-06-05 10:32:09 UTC
Comment on attachment 353174 [details] [review]
Fix memory leak in test code

I am not sure if this makes sense. The g_error() is supposed to make the unit test fail. A GST_DEBUG would no longer make the unit test fail in this case.

You would need to explain why you think the test should not fail in this case.
Comment 7 Jimmy Ohn 2017-06-05 11:44:47 UTC
Created attachment 353178 [details] [review]
Fix memory leak in test code

Actually, when I try to fix some code, I refer to test code in the tests folder each plugin. In this case, I just grepping gst_stucture_to_string in plugins-base.
But in the audioconvert test code, usage of gst_structure_to_string is different.
I know that g_error aborts, but IMHO we need to modify like another example code for consistency for gstreamer newbie like me.
Comment 8 Jimmy Ohn 2017-06-05 11:48:38 UTC
Created attachment 353179 [details] [review]
Fix memory leak in test code
Comment 9 Tim-Philipp Müller 2018-01-19 18:52:54 UTC
Ok, I have pushed another solution (in your name, hope you don't mind) that is simpler:

commit 4876fe04f589189db697b5a2e669901a9eb614ee
Author: Jimmy Ohn <yongjin.ohn@lge.com>
Date:   Mon Jun 5 14:08:33 2017 +0900

    tests: audioconvert: Fix memory leak in failure path
    
    Don't set a bad example by leaking things, even if calling
    g_error() will make the process abort.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=783418

But in general these are unit tests and we are not going to clean up stuff when they fail/abort, so this commit is more of an exception really :)