Validate window pointer before sending events for it

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 https://github.com/libsdl-org/SDL/issues/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.
This commit is contained in:
Sam Lantinga 2024-08-07 12:15:48 -07:00
parent 91d97a367e
commit 9493e6974f
1 changed files with 1 additions and 1 deletions

View File

@ -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) {