1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

Locking a NULL pointer using ScopedLock is a noop.

This commit is contained in:
Jonas 'Sortie' Termansen 2013-02-16 16:17:12 +01:00
parent bb284d9421
commit fd6098a3a2

View file

@ -61,12 +61,14 @@ public:
ScopedLock(kthread_mutex_t* mutex)
{
this->mutex = mutex;
kthread_mutex_lock(mutex);
if ( mutex )
kthread_mutex_lock(mutex);
}
~ScopedLock()
{
kthread_mutex_unlock(mutex);
if ( mutex )
kthread_mutex_unlock(mutex);
}
private:
@ -80,12 +82,12 @@ public:
ScopedLockSignal(kthread_mutex_t* mutex)
{
this->mutex = mutex;
this->acquired = kthread_mutex_lock_signal(mutex);
this->acquired = !mutex || kthread_mutex_lock_signal(mutex);
}
~ScopedLockSignal()
{
if ( acquired )
if ( mutex && acquired )
kthread_mutex_unlock(mutex);
}