SDL: Fixed memory leak in testthread (224a3)

From 224a37faabe3a074b7f0b1fd17848526961ca0a0 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sun, 28 Jul 2024 07:51:31 -0700
Subject: [PATCH] Fixed memory leak in testthread

(cherry picked from commit dfe6efcd2df1b7781ce9bbcf86963bafda589b5e)
---
 test/testthread.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/test/testthread.c b/test/testthread.c
index 031b87a6a4cf8..8e6cad18759b1 100644
--- a/test/testthread.c
+++ b/test/testthread.c
@@ -20,6 +20,7 @@
 #include "SDL_test.h"
 
 static SDL_TLSID tls;
+static SDL_Thread *thread = NULL;
 static SDL_atomic_t alive;
 static int testprio = 0;
 static SDLTest_CommonState *state;
@@ -80,13 +81,13 @@ killed(int sig)
     SDL_Log("Killed with SIGTERM, waiting 5 seconds to exit\n");
     SDL_Delay(5 * 1000);
     SDL_AtomicSet(&alive, 0);
+    SDL_WaitThread(thread, NULL);
     quit(0);
 }
 
 int main(int argc, char *argv[])
 {
-    int i = 1;
-    SDL_Thread *thread;
+    int i;
 
     state = SDLTest_CommonCreateState(argv, 0);
     if (!state) {