Skip to content

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

Open
@JSydll

Description

@JSydll

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions