SDL: SDL_test: destroy windows in SDL_CommonQuit

From 248b1edd3f282995877c35bc7de07f22f44ce55b Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Sat, 26 Aug 2023 19:34:14 +0200
Subject: [PATCH] SDL_test: destroy windows in SDL_CommonQuit

Not destroying the windows, caused a leak in checkkeys when
exiting by clicking somewhere in the window:
Allocation 0: 8 bytes
	0x7f46f56d2fe8: SDL_realloc_REAL+0x3d
	0x7f46f565deb7: GetMouseInputSource+0x88
	0x7f46f565e07b: SDL_PrivateSendMouseButton+0x56
	0x7f46f565e5aa: SDL_SendMouseButton+0x44
	0x7f46f57fb0a4: pointer_handle_button_common+0x1bb
	0x7f46f57fb0f3: pointer_handle_button+0x41
	0x7f46f5123be6: ffi_prep_go_closure+0x2c6
	0x7f46f51204bf: SDL_InitSubSystem+0x19
	0x7f46f512318e: ffi_call+0x12e
---
 src/test/SDL_test_common.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c
index 9673add95206..4cf98b63cd0c 100644
--- a/src/test/SDL_test_common.c
+++ b/src/test/SDL_test_common.c
@@ -2435,7 +2435,6 @@ void SDLTest_CommonQuit(SDLTest_CommonState *state)
     common_usage_audio = NULL;
     common_usage_videoaudio = NULL;
 
-    SDL_free(state->windows);
     if (state->targets) {
         for (i = 0; i < state->num_windows; ++i) {
             if (state->targets[i]) {
@@ -2452,6 +2451,12 @@ void SDLTest_CommonQuit(SDLTest_CommonState *state)
         }
         SDL_free(state->renderers);
     }
+    if (state->windows) {
+        for (i = 0; i < state->num_windows; i++) {
+            SDL_DestroyWindow(state->windows[i]);
+        }
+        SDL_free(state->windows);
+    }
     if (state->flags & SDL_INIT_VIDEO) {
         SDL_QuitSubSystem(SDL_INIT_VIDEO);
     }