From c7766d072b897f28754cc84e887329bba48d32ca Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Sun, 15 Jan 2023 13:30:37 +0600 Subject: [PATCH] src/Mayaqua/Unix.c: improve memory allocation handling according to Coverity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1875        if (mutex == NULL) 1876        {     CID 367204 (#1 of 1): Resource leak (RESOURCE_LEAK)4. leaked_storage: Variable lock going out of scope leaks the storage it points to. 1877                return NULL; 1878        } --- src/Mayaqua/Unix.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Mayaqua/Unix.c b/src/Mayaqua/Unix.c index 871bf9e1..922d705f 100755 --- a/src/Mayaqua/Unix.c +++ b/src/Mayaqua/Unix.c @@ -1869,11 +1869,16 @@ LOCK *UnixNewLock() pthread_mutex_t *mutex; // Memory allocation LOCK *lock = UnixMemoryAlloc(sizeof(LOCK)); + if (lock == NULL) + { + return NULL; + } // Create a mutex mutex = UnixMemoryAlloc(sizeof(pthread_mutex_t)); if (mutex == NULL) { + UnixMemoryFree(lock); return NULL; }