aboutsummaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2014-10-07 16:02:11 -0700
committerElliott Hughes <enh@google.com>2014-10-07 23:17:14 +0000
commit1543fdf616ddebee7819214437527f380e5c743b (patch)
tree17c2bc2b216c27084cdd86e7b9462fa4fa4dbec0 /libc
parent2cf155713aaba451065d593335d544f2ada24ddf (diff)
downloadbionic-1543fdf616ddebee7819214437527f380e5c743b.tar.gz
Work around a bug in Immersion's libImmEmulatorJ.so.
This library calls pthread_mutex_lock and pthread_mutex_unlock with a NULL pthread_mutex_t*. This gives them (and their users) one release to fix things. Bug: 17443936 (cherry picked from commit 7d3f553f989f830976efa92ddc3c84661d4d42aa) Change-Id: Ie26bbecd3a74d61113b51c18832872499b97ee86 (cherry picked from commit b5e7eba6d1b97e471996fcfe7dbde7cbba7512ef)
Diffstat (limited to 'libc')
-rw-r--r--libc/bionic/pthread_mutex.cpp12
-rw-r--r--libc/include/pthread.h4
2 files changed, 14 insertions, 2 deletions
diff --git a/libc/bionic/pthread_mutex.cpp b/libc/bionic/pthread_mutex.cpp
index 546166166..ae2557f08 100644
--- a/libc/bionic/pthread_mutex.cpp
+++ b/libc/bionic/pthread_mutex.cpp
@@ -440,6 +440,12 @@ static inline __always_inline int _recursive_increment(pthread_mutex_t* mutex, i
}
int pthread_mutex_lock(pthread_mutex_t* mutex) {
+#if !defined(__LP64__)
+ if (mutex == NULL) {
+ return EINVAL;
+ }
+#endif
+
int mvalue, mtype, tid, shared;
mvalue = mutex->value;
@@ -516,6 +522,12 @@ int pthread_mutex_lock(pthread_mutex_t* mutex) {
}
int pthread_mutex_unlock(pthread_mutex_t* mutex) {
+#if !defined(__LP64__)
+ if (mutex == NULL) {
+ return EINVAL;
+ }
+#endif
+
int mvalue, mtype, tid, shared;
mvalue = mutex->value;
diff --git a/libc/include/pthread.h b/libc/include/pthread.h
index 86a10051e..c32890b03 100644
--- a/libc/include/pthread.h
+++ b/libc/include/pthread.h
@@ -206,10 +206,10 @@ int pthread_mutexattr_settype(pthread_mutexattr_t*, int) __nonnull((1));
int pthread_mutex_destroy(pthread_mutex_t*) __nonnull((1));
int pthread_mutex_init(pthread_mutex_t*, const pthread_mutexattr_t*) __nonnull((1));
-int pthread_mutex_lock(pthread_mutex_t*) __nonnull((1));
+int pthread_mutex_lock(pthread_mutex_t*) /* __nonnull((1)) */;
int pthread_mutex_timedlock(pthread_mutex_t*, const struct timespec*) __nonnull((1, 2));
int pthread_mutex_trylock(pthread_mutex_t*) __nonnull((1));
-int pthread_mutex_unlock(pthread_mutex_t*) __nonnull((1));
+int pthread_mutex_unlock(pthread_mutex_t*) /* __nonnull((1)) */;
int pthread_once(pthread_once_t*, void (*)(void)) __nonnull((1, 2));