mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2024-11-22 17:39:53 +03:00
src/Mayaqua/Unix.c: improve memory allocation handling according to Coverity
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 }
This commit is contained in:
parent
8215de91f9
commit
c7766d072b
@ -1869,11 +1869,16 @@ LOCK *UnixNewLock()
|
|||||||
pthread_mutex_t *mutex;
|
pthread_mutex_t *mutex;
|
||||||
// Memory allocation
|
// Memory allocation
|
||||||
LOCK *lock = UnixMemoryAlloc(sizeof(LOCK));
|
LOCK *lock = UnixMemoryAlloc(sizeof(LOCK));
|
||||||
|
if (lock == NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// Create a mutex
|
// Create a mutex
|
||||||
mutex = UnixMemoryAlloc(sizeof(pthread_mutex_t));
|
mutex = UnixMemoryAlloc(sizeof(pthread_mutex_t));
|
||||||
if (mutex == NULL)
|
if (mutex == NULL)
|
||||||
{
|
{
|
||||||
|
UnixMemoryFree(lock);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user