diff --git a/src/thread/generic/SDL_sysmutex.c b/src/thread/generic/SDL_sysmutex.c index 42965aa8b..12cc58041 100644 --- a/src/thread/generic/SDL_sysmutex.c +++ b/src/thread/generic/SDL_sysmutex.c @@ -40,7 +40,9 @@ SDL_CreateMutex(void) SDL_mutex *mutex; /* Allocate mutex memory */ - mutex = (SDL_mutex *) SDL_malloc(sizeof(*mutex)); + mutex = (SDL_mutex *) SDL_calloc(1, sizeof(*mutex)); + +#if !SDL_THREADS_DISABLED if (mutex) { /* Create the mutex semaphore, with initial value 1 */ mutex->sem = SDL_CreateSemaphore(1); @@ -53,6 +55,8 @@ SDL_CreateMutex(void) } else { SDL_OutOfMemory(); } +#endif /* !SDL_THREADS_DISABLED */ + return mutex; }