From c12f46b100d22a0e06a64c5b6d1baa3f446d34e6 Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Mon, 22 Mar 2021 19:03:25 +0000 Subject: [PATCH] [KMSDRM] Fix segmentation fault Deference the windata pointer *after* checking that it's non-NULL. Signed-off-by: Paul Cercueil --- src/video/kmsdrm/SDL_kmsdrmvideo.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c index 4d1bc7ae6..48c2e8a3b 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.c +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c @@ -1071,7 +1071,7 @@ KMSDRM_DestroyWindow(_THIS, SDL_Window *window) { SDL_WindowData *windata = (SDL_WindowData *) window->driverdata; SDL_DisplayData *dispdata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; - SDL_VideoData *viddata = windata->viddata; + SDL_VideoData *viddata; SDL_bool is_vulkan = window->flags & SDL_WINDOW_VULKAN; /* Is this a VK window? */ unsigned int i, j; @@ -1079,6 +1079,8 @@ KMSDRM_DestroyWindow(_THIS, SDL_Window *window) return; } + viddata = windata->viddata; + if ( !is_vulkan && viddata->gbm_init) { /* Destroy cursor GBM BO of the display of this window. */