From 6de188d0251da7bc7aa7f67bbc81cf87d0a7e78f Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Wed, 17 Feb 2021 14:06:12 +0100 Subject: Fix 52317bb7: [SDL2] ensure we don't try to blit out of bounds (#8684) During resizing, there can still be dirty-rects ready to blit based on the old dimensions. X11 with shared memory enabled crashes if you try to do this. So, instead, if we resize, reset the dirty-rects. This is fine, as moments later we mark the whole (new) screen as dirty anyway. --- src/video/sdl2_v.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/video/sdl2_v.cpp b/src/video/sdl2_v.cpp index 14a8bfd1c..ce6bbc93f 100644 --- a/src/video/sdl2_v.cpp +++ b/src/video/sdl2_v.cpp @@ -351,6 +351,13 @@ bool VideoDriver_SDL::CreateMainSurface(uint w, uint h, bool resize) _sdl_surface = _sdl_real_surface; } + /* X11 doesn't appreciate it if we invalidate areas outside the window + * if shared memory is enabled (read: it crashes). So, as we might have + * gotten smaller, reset our dirty rects. GameSizeChanged() a bit lower + * will mark the whole screen dirty again anyway, but this time with the + * new dimensions. */ + _num_dirty_rects = 0; + _screen.width = _sdl_surface->w; _screen.height = _sdl_surface->h; _screen.pitch = _sdl_surface->pitch / (bpp / 8); -- cgit v1.2.3-54-g00ecf