video: Check video backend initialization when querying the grabbed window

SDL_GetGrabbedWindow() can be called when the video system is uninitialized, and, since there is no window parameter, _this must be checked for validity to avoid a segfault.

(cherry picked from commit be82f316c4)
This commit is contained in:
Frank Praznik
2026-02-19 11:15:25 -05:00
parent 4cc96e3506
commit 267f13446d

View File

@@ -4069,7 +4069,7 @@ bool SDL_GetWindowMouseGrab(SDL_Window *window)
SDL_Window *SDL_GetGrabbedWindow(void)
{
if (_this->grabbed_window &&
if (_this && _this->grabbed_window &&
(_this->grabbed_window->flags & (SDL_WINDOW_MOUSE_GRABBED | SDL_WINDOW_KEYBOARD_GRABBED)) != 0) {
return _this->grabbed_window;
} else {