From 0eff3fe55887dec8cc741d06313648094b9bb021 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 18 Sep 2025 20:26:19 -0700 Subject: [PATCH] Fixed double-free when using window surfaces --- src/video/SDL_video.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index e265632db6..fec42cfc37 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -4429,6 +4429,8 @@ void SDL_DestroyWindow(SDL_Window *window) SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_DESTROYED, 0, 0); + SDL_DestroyWindowSurface(window); + SDL_Renderer *renderer = SDL_GetRenderer(window); if (renderer) { SDL_DestroyRendererWithoutFreeing(renderer); @@ -4469,8 +4471,6 @@ void SDL_DestroyWindow(SDL_Window *window) SDL_SetMouseFocus(NULL); } - SDL_DestroyWindowSurface(window); - // Make no context current if this is the current context window if (window->flags & SDL_WINDOW_OPENGL) { if (_this->current_glwin == window) {