-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ladspa plugin small memory leak fix #3496
Conversation
This patch is wrong because you are not supposed to free |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should try an approach that respects const
.
@@ -334,9 +334,13 @@ void ladspa_plugin_metadata_set::prepare(const plugin_metadata_iface *md, LADSPA | |||
param_count = md->get_param_count(); // XXXKF ladspa_instance<Module>::real_param_count(); | |||
|
|||
const ladspa_plugin_info &plugin_info = md->get_plugin_info(); | |||
std::string strName(plugin_info.name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use spaces in this file.
descriptor.UniqueID = plugin_info.unique_id; | ||
descriptor.Label = plugin_info.label; | ||
descriptor.Name = strdup((std::string(plugin_info.name) + " LADSPA").c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strdup
is fine. You just need to save the result somewhere else. It is not as efficient, but correctness is more important.
@@ -467,13 +475,16 @@ ladspa_plugin_metadata_set::~ladspa_plugin_metadata_set() | |||
delete []descriptor.PortNames; | |||
delete []descriptor.PortDescriptors; | |||
delete []descriptor.PortRangeHints; | |||
delete []descriptor.Name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are not supposed to delete const
memory.
#endif | ||
delete metadata; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
metadata
is const
. You should go to the point where metadata
is created, make sure you keep a reference, and release it on destruction; you may need a function with __attribute__((destructor))
.
@devnexen I'm sorry this took so long to review, the original reviewer is no longer with the project. Calf has been moved to a submodule since #3940 and I missed this patch. Currently @JohannesLorenz is working on getting Calf updated to 0.90, so this patch could have a home in either the current 0.18~ish version on the Closing since the code this PR is against is no longer part of the LMMS codebase. |
No description provided.