GNOME Bugzilla – Bug 735348
Memory leak in Acm components
Last modified: 2014-08-26 06:52:04 UTC
On reviewing the code of AcmEnc.c and AcmMp3Dec.c could see that there are possible memory leaks. in *_setup functions, there are memory allocations for pbSrc and pbDst. Now when there are no other errors, *->is_setup variable will be set to true. Hence on calling setup again in *_sink_setcaps function, since is_setup variable is true it will teardown and call setup again. In this case there will be no leaks. Now during *_setup call, if it fails to prepare ACM stream, the variable is_setup will not be set to true. Hence when we try to create the element, it will not teardown, and the previous allocations will not be freed. Hence i added free functions when ACM stream fails to prepare. And i feel it is always better to free memory in failure cases in the same function, rather than waiting for teardown to free them.
Created attachment 284370 [details] [review] Patch for AcmEnc memory leak fix
Created attachment 284371 [details] [review] Patch for AcmMp3Dec memory leak
FYI acm plugins were not ported to 1.0 and I'm not sure if it is worth porting them as DirectShow should be the recommended framework instead of ACM or VCM for Windows.
Hi Thiago, Yes i came to know that ACM is not ported to 1.0. Since i dont have a windows setup, i didnt try to port as well. But i just went through the code and found these leaks. Thought this might help anyone in future who tries to port the same. PS: I am new to GStreamer, and this was the first element i looked into :).. Regards, Vineeth
Thanks for filing the bug and patch, but we don't usually modify source code of plugins which haven't been ported and which can't be compiled and tested. Best to leave them alone. The code will likely be rewritten quite a bit when it gets ported.