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:
Sam Lantinga
2024-07-18 15:56:41 -07:00
parent ef884c8aa6
commit bb96320cc4
19 changed files with 66 additions and 71 deletions

View File

@@ -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);
}
}