summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2011-07-03 15:26:44 +0000
committerguenther <guenther@openbsd.org>2011-07-03 15:26:44 +0000
commite3b964e5ef4cc0de584def76f49a8b3db066e4de (patch)
tree7b06ab089fbfc5f1749224df8d985dc3b4ad0133
parentThe BUGS that MANPS and MANZ are not supported in ports (diff)
downloadwireguard-openbsd-e3b964e5ef4cc0de584def76f49a8b3db066e4de.tar.xz
wireguard-openbsd-e3b964e5ef4cc0de584def76f49a8b3db066e4de.zip
In pthread_key_delete(), only scan other threads if the key was allocated
and handle the case of specific_data being NULL. Pointed out by fgsch@, ok tedu@
-rw-r--r--lib/libpthread/uthread/uthread_spec.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/libpthread/uthread/uthread_spec.c b/lib/libpthread/uthread/uthread_spec.c
index eecf07d10e4..f01e91bbf0e 100644
--- a/lib/libpthread/uthread/uthread_spec.c
+++ b/lib/libpthread/uthread/uthread_spec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uthread_spec.c,v 1.10 2011/07/02 17:12:02 tedu Exp $ */
+/* $OpenBSD: uthread_spec.c,v 1.11 2011/07/03 15:26:44 guenther Exp $ */
/*
* Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
* All rights reserved.
@@ -84,20 +84,20 @@ pthread_key_delete(pthread_key_t key)
/* Lock the key table entry: */
_SPINLOCK(&key_table[key].lock);
- if (key_table[key].allocated)
+ if (key_table[key].allocated) {
key_table[key].allocated = 0;
- else
- ret = EINVAL;
- _thread_kern_sig_defer();
- TAILQ_FOREACH(pthread, &_thread_list, tle) {
- if (pthread->specific_data[key]) {
- pthread->specific_data[key] = NULL;
- pthread->specific_data_count--;
+ _thread_kern_sig_defer();
+ TAILQ_FOREACH(pthread, &_thread_list, tle) {
+ if (pthread->specific_data != NULL &&
+ pthread->specific_data[key]) {
+ pthread->specific_data[key] = NULL;
+ pthread->specific_data_count--;
+ }
}
-
- }
- _thread_kern_sig_undefer();
+ _thread_kern_sig_undefer();
+ } else
+ ret = EINVAL;
/* Unlock the key table entry: */
_SPINUNLOCK(&key_table[key].lock);