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

Protect string comparisons against segfaults #547

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

JSydll
Copy link

@JSydll JSydll commented Dec 3, 2024

This intends to resolve #546.

Comparing string objects to nullptr is not prevented by the implementation. Therefore, it should check before starting the actual comparison - which currently leads to a segfault due to the unprotected use of CharStrlen. Given that CharStrlen fulfills the standard specification of showing UB when called like that, the issue should be fixed on the calling site.

The first commit introduces minimal test cases for the global equality operators for basic_string, the second the (quite small) fix.

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.

string.h: Missing nullptr handling in operator== leading to segfaults
1 participant