From 8a5ee3faf940a32075a9820bac6950bd93881ef4 Mon Sep 17 00:00:00 2001 From: Jay Petacat Date: Sun, 12 Apr 2020 00:55:52 -0400 Subject: [PATCH] video: NULL out pointer to freed window surface This behavior matches SDL_RecreateWindow and makes it less likely that another piece of code (e.g. a DestroyWindowFramebuffer implementation) will attempt to use or free the stale surface pointer. --- src/video/SDL_video.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index b6d083a53..d8778aa4d 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -2796,6 +2796,8 @@ SDL_DestroyWindow(SDL_Window * window) if (window->surface) { window->surface->flags &= ~SDL_DONTFREE; SDL_FreeSurface(window->surface); + window->surface = NULL; + window->surface_valid = SDL_FALSE; } if (_this->DestroyWindowFramebuffer) { _this->DestroyWindowFramebuffer(_this, window);