changeset 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 eed579d059ef
children 6ca967a46bf1
files src/thread/SDL_thread.c
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
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",