Commit fcd7d658dce17d2e15079a74cc301330727acafe

pionere 2022-11-29T11:18:30

thread: fix inconsistent return values - SDL_CreateMutex returns NULL when the creation fails (ngage) - SDL_SemValue returns 0 when the semaphore is NULL (n3ds) (cherry picked from commit 6875e1c262ae968a4fb52b367cf6912d9c76d4c9)

diff --git a/src/thread/n3ds/SDL_syssem.c b/src/thread/n3ds/SDL_syssem.c
index ee0b49f..0621e8a 100644
--- a/src/thread/n3ds/SDL_syssem.c
+++ b/src/thread/n3ds/SDL_syssem.c
@@ -114,7 +114,8 @@ Uint32
 SDL_SemValue(SDL_sem *sem)
 {
     if (sem == NULL) {
-        return SDL_InvalidParamError("sem");
+        SDL_InvalidParamError("sem");
+        return 0;
     }
     return sem->semaphore.current_count;
 }
diff --git a/src/thread/ngage/SDL_sysmutex.cpp b/src/thread/ngage/SDL_sysmutex.cpp
index e6f5bfb..3878871 100644
--- a/src/thread/ngage/SDL_sysmutex.cpp
+++ b/src/thread/ngage/SDL_sysmutex.cpp
@@ -48,6 +48,7 @@ SDL_CreateMutex(void)
     TInt status = CreateUnique(NewMutex, &rmutex, NULL);
     if (status != KErrNone) {
         SDL_SetError("Couldn't create mutex.");
+        return NULL;
     }
     SDL_mutex* mutex = new /*(ELeave)*/ SDL_mutex;
     mutex->handle = rmutex.Handle();