EASTL icon indicating copy to clipboard operation
EASTL copied to clipboard

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

Open JSydll opened this issue 1 year ago • 0 comments

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 avatar Dec 02 '24 11:12 JSydll