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

Deallocate m_mem only if not nullptr #13

Merged

Conversation

mweisgut
Copy link
Contributor

@mweisgut mweisgut commented Jan 27, 2025

The deconstructor tries to deallocate memory for a given nulltpr if the move constructor has been used before. If the allocator is an std::pmr::polymorphic_allocator, the memory resource's deallocate function will be called with a nullptr. This is undefined behavior.

This PR adds a simple check so that the deconstructor only deallocates m_mem if it is not nullptr.

@gmarcais
Copy link
Owner

The difference between deallocate and delete regarding nullptr is surprising. Anyway, you are correct. Thank you for the patch and PR.

@gmarcais gmarcais changed the base branch from master to develop January 27, 2025 15:24
@gmarcais gmarcais merged commit eb83803 into gmarcais:develop Jan 27, 2025
12 checks passed
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.

2 participants