Skip to content

Commit

Permalink
Reduce the possibility of SDL_LockMutex getting called on a destroyed…
Browse files Browse the repository at this point in the history
… mutex after SDL_StopEventLoop
  • Loading branch information
slouken committed Dec 19, 2024
1 parent 519923e commit 6e0df0a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/events/SDL_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -886,12 +886,17 @@ void SDL_StopEventLoop(void)
}
SDL_zero(SDL_EventOK);

SDL_UnlockMutex(SDL_EventQ.lock);

SDL_Mutex *lock = NULL;
if (SDL_EventQ.lock) {
SDL_DestroyMutex(SDL_EventQ.lock);
lock = SDL_EventQ.lock;
SDL_EventQ.lock = NULL;
}

SDL_UnlockMutex(lock);

if (lock) {
SDL_DestroyMutex(lock);
}
}

// This function (and associated calls) may be called more than once
Expand Down

0 comments on commit 6e0df0a

Please sign in to comment.