diff options
author | David 'Digit' Turner <digit@google.com> | 2010-06-28 14:20:22 -0700 |
---|---|---|
committer | David 'Digit' Turner <digit@google.com> | 2010-06-28 14:20:22 -0700 |
commit | a02b93bd75a9d156117264d88069566e447397e2 (patch) | |
tree | 82f11630b57fc7a9defa24b8e2955a5614275d1c /libc/bionic | |
parent | 0621a279adfb981ea1f0564e7fc8280cda78e043 (diff) | |
download | bionic-a02b93bd75a9d156117264d88069566e447397e2.zip bionic-a02b93bd75a9d156117264d88069566e447397e2.tar.gz bionic-a02b93bd75a9d156117264d88069566e447397e2.tar.bz2 |
libc: add sanity checks to pthread_mutex_destroy()
Change-Id: Iddb2204fa792fa9aca5f19838926dddbb09b74a2
Diffstat (limited to 'libc/bionic')
-rw-r--r-- | libc/bionic/pthread.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libc/bionic/pthread.c b/libc/bionic/pthread.c index 061cce1..e21a1f9 100644 --- a/libc/bionic/pthread.c +++ b/libc/bionic/pthread.c @@ -880,8 +880,13 @@ int pthread_mutex_init(pthread_mutex_t *mutex, int pthread_mutex_destroy(pthread_mutex_t *mutex) { - if (__unlikely(mutex == NULL)) - return EINVAL; + int ret; + + /* use trylock to ensure that the mutex value is + * valid and is not already locked. */ + ret = pthread_mutex_trylock(mutex); + if (ret != 0) + return ret; mutex->value = 0xdead10cc; return 0; |