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

[Bug] Fix null pointer deref in Clay_SetPointerState #33

Merged
merged 3 commits into from
Oct 2, 2024

Conversation

SogoCZE
Copy link
Contributor

@SogoCZE SogoCZE commented Oct 2, 2024

In some situations mapItem in Clay_SetPointerState can end up being null which results in to crash (because elementId is being accessed on null mapItem).

An example of this behaviour can be seen when you have an empty layout with only one text:

Clay_BeginLayout();

CLAY_TEXT(
    CLAY_ID("HelloWorldText"), 
    CLAY_STRING("Hello World!"),
    CLAY_TEXT_CONFIG(
        .fontId = FONT_ID_BODY_24, 
        .fontSize = 24,
         .textColor = {255, 0, 0, 255}
    )
);
                             
return Clay_EndLayout();

@nicbarker
Copy link
Owner

Hello, thanks for reporting this one! Taking a look now 👀

@nicbarker
Copy link
Owner

Seems like the entire second half of that if statement was just an incorrect case. Must have been left over from a refactor or something. Nice catch!

@nicbarker nicbarker merged commit 987e7fd into nicbarker:main Oct 2, 2024
3 checks passed
@nicbarker nicbarker changed the title Fix of a crash when mapItem is null Fix bug null pointer deref in Clay_SetPointerState Oct 2, 2024
@nicbarker nicbarker changed the title Fix bug null pointer deref in Clay_SetPointerState [Bug] Fix null pointer deref in Clay_SetPointerState Oct 2, 2024
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