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

Error Handler Memory Leak #466

Closed
Steven-Roberts opened this issue May 3, 2024 · 3 comments · Fixed by #467
Closed

Error Handler Memory Leak #466

Steven-Roberts opened this issue May 3, 2024 · 3 comments · Fixed by #467
Labels

Comments

@Steven-Roberts
Copy link
Collaborator

If more than default error handler is added to a SUNContext, it does not get free'd in SUNContext_Free.

SUNErrHandler_Destroy(&(*sunctx)->err_handler);

void SUNErrHandler_Destroy(SUNErrHandler* eh)
{
if (!eh || !(*eh)) { return; }
free(*eh);
*eh = NULL;
}

Either SUNContext_Free or SUNErrHandler_Destroy should traverse the list of error handlers through sunctx->err_handler->previous to free each.

@gardner48
Copy link
Member

SUNErrHandler_Destroy(&(*sunctx)->err_handler);

This call to SUNErrHandler_Destory should be replaced with SUNContext_ClearErrHandlers

@Steven-Roberts
Copy link
Collaborator Author

Ah great, there's already a function to do that. I swapped in SUNContext_ClearErrHandlers and valgrind reports no leaks. I'll turn it into a PR.

@Steven-Roberts Steven-Roberts linked a pull request May 3, 2024 that will close this issue
@balos1
Copy link
Member

balos1 commented May 5, 2024

Closed by #467

@balos1 balos1 closed this as completed May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants