Commit 82fe1ff6 authored by Sam Lantinga's avatar Sam Lantinga

Fix potential use of freed memory in the threaded timer system

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401024
parent bef6a4f3
...@@ -45,7 +45,7 @@ int SDL_timer_running = 0; ...@@ -45,7 +45,7 @@ int SDL_timer_running = 0;
Uint32 SDL_alarm_interval = 0; Uint32 SDL_alarm_interval = 0;
SDL_TimerCallback SDL_alarm_callback; SDL_TimerCallback SDL_alarm_callback;
static SDL_bool list_changed = SDL_FALSE; static volatile SDL_bool list_changed = SDL_FALSE;
/* Data used for a thread-based timer */ /* Data used for a thread-based timer */
static int SDL_timer_threaded = 0; static int SDL_timer_threaded = 0;
...@@ -114,6 +114,9 @@ void SDL_ThreadedTimerCheck(void) ...@@ -114,6 +114,9 @@ void SDL_ThreadedTimerCheck(void)
Uint32 now, ms; Uint32 now, ms;
SDL_TimerID t, prev, next; SDL_TimerID t, prev, next;
int removed; int removed;
SDL_NewTimerCallback callback;
Uint32 interval;
void *param;
now = SDL_GetTicks(); now = SDL_GetTicks();
...@@ -133,8 +136,11 @@ void SDL_ThreadedTimerCheck(void) ...@@ -133,8 +136,11 @@ void SDL_ThreadedTimerCheck(void)
printf("Executing timer %p (thread = %d)\n", printf("Executing timer %p (thread = %d)\n",
t, SDL_ThreadID()); t, SDL_ThreadID());
#endif #endif
callback = t->cb;
interval = t->interval;
param = t->param;
SDL_mutexV(SDL_timer_mutex); SDL_mutexV(SDL_timer_mutex);
ms = t->cb(t->interval, t->param); ms = callback(interval, param);
SDL_mutexP(SDL_timer_mutex); SDL_mutexP(SDL_timer_mutex);
if ( list_changed ) { if ( list_changed ) {
/* Abort, list of timers has been modified */ /* Abort, list of timers has been modified */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment