fix crash if pthread_mutex_unlock is called without ever locking

this is valid for error-checking mutexes; otherwise it invokes UB and
would be justified in crashing.
This commit is contained in:
Rich Felker 2011-10-03 00:11:16 -04:00
parent 7fe58d3511
commit b8688ff875
1 changed files with 1 additions and 1 deletions

View File

@ -9,7 +9,7 @@ int pthread_mutex_unlock(pthread_mutex_t *m)
if (m->_m_type != PTHREAD_MUTEX_NORMAL) { if (m->_m_type != PTHREAD_MUTEX_NORMAL) {
if (!m->_m_lock) if (!m->_m_lock)
return EPERM; return EPERM;
self = __pthread_self(); self = pthread_self();
if ((m->_m_lock&0x1fffffff) != self->tid) if ((m->_m_lock&0x1fffffff) != self->tid)
return EPERM; return EPERM;
if ((m->_m_type&3) == PTHREAD_MUTEX_RECURSIVE && m->_m_count) if ((m->_m_type&3) == PTHREAD_MUTEX_RECURSIVE && m->_m_count)