Parcourir la source

src/io/SDL_asyncio.c:SDL_AsyncIOFromFile(): Fix null-dereference warning

Petar Popovic il y a 1 mois
Parent
commit
ad11c6988c
1 fichiers modifiés avec 8 ajouts et 6 suppressions
  1. 8 6
      src/io/SDL_asyncio.c

+ 8 - 6
src/io/SDL_asyncio.c

@@ -57,12 +57,14 @@ SDL_AsyncIO *SDL_AsyncIOFromFile(const char *file, const char *mode)
     }
 
     SDL_AsyncIO *asyncio = (SDL_AsyncIO *)SDL_calloc(1, sizeof(*asyncio));
-    if (asyncio) {
-        asyncio->lock = SDL_CreateMutex();
-        if (!asyncio->lock) {
-            SDL_free(asyncio);
-            return NULL;
-        }
+    if (!asyncio) {
+        return NULL;
+    }
+
+    asyncio->lock = SDL_CreateMutex();
+    if (!asyncio->lock) {
+        SDL_free(asyncio);
+        return NULL;
     }
 
     if (!SDL_SYS_AsyncIOFromFile(file, binary_mode, asyncio)) {