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:
parent
bb284d9421
commit
fd6098a3a2
1 changed files with 6 additions and 4 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue