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 committed 2024-07-19 12:22:03 -07:00
1 parent ef884c8aa6
commit bb96320cc4
19 files changed
+66 -71

No files matched your search

+1 -1
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);
}
}