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

string.h: Missing nullptr handling in operator== leading to segfaults #546

Open
JSydll opened this issue Dec 2, 2024 · 0 comments · May be fixed by #547
Open

string.h: Missing nullptr handling in operator== leading to segfaults #546

JSydll opened this issue Dec 2, 2024 · 0 comments · May be fixed by #547

Comments

@JSydll
Copy link

JSydll commented Dec 2, 2024

Users of the EASTL might compare a string object to nullptr. While this is actually a useless operation, given string objects cannot be NULL, it may occurr in templated code and ripple down to the point where CharStrlen from char_traits.h is called with a nullptr, triggering a segfault.

A real life example for this is when EASTL is used with the trompeloeil mocking framework.

Minimal demo:

#include <EASTL/fixed_string.h>

int main() {
    constexpr size_t minSize{2U};
    eastl::fixed_string<char, minSize, false> fs;
    if (fs == nullptr)
    {
        // This is useless as it can never occur. But it will segfault.
    }
}

Imho, there shall be a check for null in the operator== implementation(s).

@JSydll JSydll linked a pull request Dec 3, 2024 that will close this issue
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 a pull request may close this issue.

1 participant