From 5c2320f113402b7450e01e2093286663adf27ecc Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 7 Oct 2016 17:58:02 -0700 Subject: [PATCH] Fixed bug 3022 - SDL_UnlockMutex(SDL_EventQ.lock) in SDL_PeepEvents can cause error when lock is null --- src/events/SDL_events.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c index 0af027045..2f5b0af29 100644 --- a/src/events/SDL_events.c +++ b/src/events/SDL_events.c @@ -332,7 +332,9 @@ SDL_PeepEvents(SDL_Event * events, int numevents, SDL_eventaction action, } } } - SDL_UnlockMutex(SDL_EventQ.lock); + if (SDL_EventQ.lock) { + SDL_UnlockMutex(SDL_EventQ.lock); + } } else { return SDL_SetError("Couldn't lock event queue"); } @@ -374,7 +376,7 @@ SDL_FlushEvents(Uint32 minType, Uint32 maxType) #endif /* Lock the event queue */ - if (SDL_LockMutex(SDL_EventQ.lock) == 0) { + if (SDL_EventQ.lock && SDL_LockMutex(SDL_EventQ.lock) == 0) { SDL_EventEntry *entry, *next; Uint32 type; for (entry = SDL_EventQ.head; entry; entry = next) {