mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-17 16:58:13 +00:00
Make sure we always copy the data returned using SDL_GetStringRule
This prevents race conditions where calling an API from one thread returns the data and it's freed by updates on another thread
This commit is contained in:
@@ -329,7 +329,7 @@ void SDL_RunThread(SDL_Thread *thread)
|
||||
if (!SDL_AtomicCompareAndSwap(&thread->state, SDL_THREAD_STATE_ALIVE, SDL_THREAD_STATE_ZOMBIE)) {
|
||||
/* Clean up if something already detached us. */
|
||||
if (SDL_AtomicCompareAndSwap(&thread->state, SDL_THREAD_STATE_DETACHED, SDL_THREAD_STATE_CLEANED)) {
|
||||
SDL_FreeLater(thread->name);
|
||||
SDL_free(thread->name); /* Can't free later, we've already cleaned up TLS */
|
||||
SDL_free(thread);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user