sdl12-compat: video: Fixed memory leak in video subsystem quit.

From db10d6fc01a2a567ddf58e9890b3bbeb6fa5c77c Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Fri, 13 Jan 2023 11:45:58 -0500
Subject: [PATCH] video: Fixed memory leak in video subsystem quit.

Fixes #284.
---
 src/SDL12_compat.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c
index 219653cb4..b8749d080 100644
--- a/src/SDL12_compat.c
+++ b/src/SDL12_compat.c
@@ -5430,10 +5430,11 @@ EndVidModeCreate(void)
         VideoPhysicalPalette20 = NULL;
     }
     if (VideoSurface12) {
+        SDL12_Surface *screen12 = VideoSurface12;
         SDL20_free(VideoSurface12->pixels);
         VideoSurface12->pixels = NULL;
-        SDL_FreeSurface(VideoSurface12);
-        VideoSurface12 = NULL;
+        VideoSurface12 = NULL;  /* SDL_FreeSurface will ignore the screen surface, so NULL the global variable out. */
+        SDL_FreeSurface(screen12);
     }
     if (VideoConvertSurface20) {
         SDL20_FreeSurface(VideoConvertSurface20);