Fixed a minor memory leak in the SDL thread subsystem
authorSam Lantinga <slouken@libsdl.org>
Thu, 11 Apr 2002 21:08:44 +0000
changeset 340 b9f1ce709960
parent 339 eed579d059ef
child 341 6ca967a46bf1
Fixed a minor memory leak in the SDL thread subsystem
src/thread/SDL_thread.c
--- a/src/thread/SDL_thread.c	Thu Apr 11 18:22:05 2002 +0000
+++ b/src/thread/SDL_thread.c	Thu Apr 11 21:08:44 2002 +0000
@@ -146,10 +146,15 @@
 			}
 		}
 		if ( i < SDL_numthreads ) {
-			--SDL_numthreads;
-			while ( i < SDL_numthreads ) {
-				SDL_Threads[i] = SDL_Threads[i+1];
-				++i;
+			if ( --SDL_numthreads > 0 ) {
+				while ( i < SDL_numthreads ) {
+					SDL_Threads[i] = SDL_Threads[i+1];
+					++i;
+				}
+			} else {
+				SDL_maxthreads = 0;
+				free(SDL_Threads);
+				SDL_Threads = NULL;
 			}
 #ifdef DEBUG_THREADS
 			printf("Deleting thread (%d left - %d max)\n",