Plugins (Blursk): Fix double free when Blursk is loaded multiple times. #382
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Blursk crashes in
__blursk_cleanup
when the plugin is loaded and unloaded multiple times. This can occur whenlv-tool
cycles through actors and completes a full rotation.The bug is due to the sharing and re-use of the variable
config
across instances.config
contains multiple strings allocated during plugin instance initialization inconfig_default()
:These strings are then freed in
__blursk_cleanup()
when the plugin instance is cleaned up.After freeing the strings in the first instance, these pointer values remain unchanged and the next run of
config_default()
crashes the program.The solution is to unshare the
config
struct but I ran into a header inclusion cycle with my attempt. Breaking the cycle requires a fair amount of refactoring, so I decided to instead zero out theconfig
struct to complete the clean-up.We can come back to this after a more thorough review of the plugin system.