summaryrefslogtreecommitdiffstats
path: root/lib/libpthread
diff options
context:
space:
mode:
authorkurt <kurt@openbsd.org>2008-06-20 02:58:00 +0000
committerkurt <kurt@openbsd.org>2008-06-20 02:58:00 +0000
commit35e72e6bd08ecffc84101bc18c27d7129fc59900 (patch)
tree3b5dc63fd7b857eb200b95e5c2d02c421320a810 /lib/libpthread
parentknf; Mark Lumsden (diff)
downloadwireguard-openbsd-35e72e6bd08ecffc84101bc18c27d7129fc59900.tar.xz
wireguard-openbsd-35e72e6bd08ecffc84101bc18c27d7129fc59900.zip
Adjust the _SEM_CHECK_VALIDITY macro to detect NULL sem_t instead of
segfaulting. okay marc@ todd@
Diffstat (limited to 'lib/libpthread')
-rw-r--r--lib/libpthread/uthread/uthread_sem.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libpthread/uthread/uthread_sem.c b/lib/libpthread/uthread/uthread_sem.c
index 7078449aad2..925910cbda5 100644
--- a/lib/libpthread/uthread/uthread_sem.c
+++ b/lib/libpthread/uthread/uthread_sem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uthread_sem.c,v 1.2 2007/05/18 19:28:50 kurt Exp $ */
+/* $OpenBSD: uthread_sem.c,v 1.3 2008/06/20 02:58:00 kurt Exp $ */
/*
* Copyright (C) 2000 Jason Evans <jasone@freebsd.org>.
* All rights reserved.
@@ -38,7 +38,9 @@
#include "pthread_private.h"
#define _SEM_CHECK_VALIDITY(sem) \
- if ((*(sem))->magic != SEM_MAGIC) { \
+ if ((sem) == NULL || \
+ *(sem) == NULL || \
+ (*(sem))->magic != SEM_MAGIC) { \
errno = EINVAL; \
retval = -1; \
goto RETURN; \