Skip to content

Commit

Permalink
Validate window pointer before sending events for it
Browse files Browse the repository at this point in the history
If there are bugs it's possible that the window pointer is invalid. Double check it before sending the application events and potentially dereferencing it.

This showed up in libsdl-org#10494 as a window getting mouse focus as it was being destroyed and then crashing later when mouse focus was set to a different window.
  • Loading branch information
slouken committed Aug 7, 2024
1 parent ab54503 commit 6dedf71
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/events/SDL_windowevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ int SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent,
{
int posted;

if (!window) {
if (!SDL_ObjectValid(window, SDL_OBJECT_TYPE_WINDOW)) {
return 0;
}
if (window->is_destroying && windowevent != SDL_EVENT_WINDOW_DESTROYED) {
Expand Down

0 comments on commit 6dedf71

Please sign in to comment.