mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-15 14:26:01 +00:00
wayland: Ensure that a NULL internal structure isn't dereferenced when destroying a window
In some cases, such as when recreating a window during renderer initialization, a failure can leave the window in a state where the internal structure has already been freed, but the higher level window object needs to be destroyed separately. Check that the internal handle is valid before attempting to access any data during destruction. Allows for graceful failure instead of a crash during cleanup if renderer creation fails.
This commit is contained in:
@@ -2818,13 +2818,14 @@ void Wayland_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
SDL_VideoData *data = _this->internal;
|
||||
SDL_WindowData *wind = window->internal;
|
||||
|
||||
if (data && wind) {
|
||||
/* Roundtrip before destroying the window to make sure that it has received input leave events, so that
|
||||
* no internal structures are left pointing to the destroyed window. */
|
||||
* no internal structures are left pointing to the destroyed window.
|
||||
*/
|
||||
if (wind->show_hide_sync_required) {
|
||||
WAYLAND_wl_display_roundtrip(data->display);
|
||||
}
|
||||
|
||||
if (data && wind) {
|
||||
#ifdef SDL_VIDEO_OPENGL_EGL
|
||||
if (wind->egl_surface) {
|
||||
SDL_EGL_DestroySurface(_this, wind->egl_surface);
|
||||
|
Reference in New Issue
Block a user