From: guenther Date: Thu, 14 Aug 2008 05:57:06 +0000 (+0000) Subject: Match libpthread's behavior and make pthread_join(NULL, whatever) fail X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=4b3fbaa6d58a982e33cb68b9c9f7b130d2dafebb;p=openbsd Match libpthread's behavior and make pthread_join(NULL, whatever) fail instead of crashing ok kurt@ first observed by Jung --- diff --git a/lib/librthread/rthread.c b/lib/librthread/rthread.c index decb31e1c5b..da0a7564591 100644 --- a/lib/librthread/rthread.c +++ b/lib/librthread/rthread.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rthread.c,v 1.37 2008/08/14 05:20:44 guenther Exp $ */ +/* $OpenBSD: rthread.c,v 1.38 2008/08/14 05:57:06 guenther Exp $ */ /* * Copyright (c) 2004,2005 Ted Unangst * All Rights Reserved. @@ -231,7 +231,9 @@ pthread_join(pthread_t thread, void **retval) { int e; - if (thread->tid == getthrid()) + if (thread == NULL) + e = EINVAL; + else if (thread->tid == getthrid()) e = EDEADLK; else if (thread->flags & THREAD_DETACHED) e = EINVAL;