Skip to content
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

Closed
wants to merge 4 commits into from
Closed

Ladspa plugin small memory leak fix #3496

wants to merge 4 commits into from

Conversation

devnexen
Copy link
Contributor

@devnexen devnexen commented Apr 9, 2017

No description provided.

@jasp00
Copy link
Member

jasp00 commented Apr 9, 2017

This patch is wrong because you are not supposed to free const memory. You should try a different approach.

Copy link
Member

@jasp00 jasp00 left a 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);
Copy link
Member

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());
Copy link
Member

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;
Copy link
Member

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;
Copy link
Member

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)).

@Umcaruje Umcaruje added this to the 1.3.0 milestone May 14, 2017
@tresf
Copy link
Member

tresf commented Nov 15, 2017

@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 ladspa branch or the 0.90 version on the master branch.

Closing since the code this PR is against is no longer part of the LMMS codebase.

@tresf tresf closed this Nov 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants