From b04fefbc662e23ff7680ea5223fea4ddae29f392 Mon Sep 17 00:00:00 2001 From: Kurt Miller Date: Fri, 20 Jun 2008 02:58:01 +0000 Subject: Adjust the _SEM_CHECK_VALIDITY macro to detect NULL sem_t instead of segfaulting. okay marc@ todd@ --- lib/libpthread/uthread/uthread_sem.c | 6 ++++-- 1 file 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 . * 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; \ -- cgit v1.2.3