diff src/thread/SDL_thread.c @ 340:b9f1ce709960

Fixed a minor memory leak in the SDL thread subsystem
author Sam Lantinga <slouken@libsdl.org>
date Thu, 11 Apr 2002 21:08:44 +0000
parents 1d74ddc90cb2
children 283d348cb624
line wrap: on
line diff
--- 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",