summaryrefslogtreecommitdiffstats
path: root/lib/libpthread/thread/thr_join.c
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2003-07-07 04:28:23 +0000
committerdavidxu <davidxu@FreeBSD.org>2003-07-07 04:28:23 +0000
commit8aa4e2d6856d1eed699b30ccca6163f8e501e183 (patch)
tree6539674ba4c0ff3018faf64006ac81eb9090ec5f /lib/libpthread/thread/thr_join.c
parente95dd66c1f7fd662d47b34b5d83f1dcaa8b150e3 (diff)
downloadFreeBSD-src-8aa4e2d6856d1eed699b30ccca6163f8e501e183.zip
FreeBSD-src-8aa4e2d6856d1eed699b30ccca6163f8e501e183.tar.gz
Avoid accessing user provided parameters in critical region.
Reviewed by: deischen
Diffstat (limited to 'lib/libpthread/thread/thr_join.c')
-rw-r--r--lib/libpthread/thread/thr_join.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/libpthread/thread/thr_join.c b/lib/libpthread/thread/thr_join.c
index d6add88..592aa3a 100644
--- a/lib/libpthread/thread/thr_join.c
+++ b/lib/libpthread/thread/thr_join.c
@@ -41,6 +41,7 @@ int
_pthread_join(pthread_t pthread, void **thread_return)
{
struct pthread *curthread = _get_curthread();
+ void *tmp;
kse_critical_t crit;
int ret = 0;
@@ -80,9 +81,8 @@ _pthread_join(pthread_t pthread, void **thread_return)
} else {
/* Lock the target thread while checking its state. */
if (pthread->state == PS_DEAD) {
- if (thread_return != NULL)
- /* Return the thread's return value: */
- *thread_return = pthread->ret;
+ /* Return the thread's return value: */
+ tmp = pthread->ret;
/* Detach the thread. */
pthread->attr.flags |= PTHREAD_DETACHED;
@@ -103,6 +103,8 @@ _pthread_join(pthread_t pthread, void **thread_return)
/* Remove the reference. */
_thr_ref_delete(curthread, pthread);
+ if (thread_return != NULL)
+ *thread_return = tmp;
}
else if (pthread->joiner != NULL) {
/* Unlock the thread and remove the reference. */
OpenPOWER on IntegriCloud