From b3e91e9179a85320d6e4aa63780cb653ff6a5a0e Mon Sep 17 00:00:00 2001 From: rpj Date: Wed, 18 Jul 2001 07:41:47 +0000 Subject: Fix potential NULL pointer dereferences. Contributed by - "Scott McCaskill" * mutex.c (pthread_mutexattr_init): Return ENOMEM immediately and don't dereference the NULL pointer if calloc fails. (pthread_mutexattr_getpshared): Don't dereference a pointer that is possibly NULL. * barrier.c (pthread_barrierattr_init): Likewise (pthread_barrierattr_getpshared): Don't dereference a pointer that is possibly NULL. * condvar.c (pthread_condattr_getpshared): Don't dereference a pointer that is possibly NULL. --- mutex.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'mutex.c') diff --git a/mutex.c b/mutex.c index f32cf18..49a1a18 100644 --- a/mutex.c +++ b/mutex.c @@ -290,10 +290,10 @@ pthread_mutexattr_init (pthread_mutexattr_t * attr) { ma->pshared = PTHREAD_PROCESS_PRIVATE; ma->kind = PTHREAD_MUTEX_DEFAULT; - - *attr = ma; } + *attr = ma; + return(result); } /* pthread_mutexattr_init */ @@ -384,16 +384,16 @@ pthread_mutexattr_getpshared (const pthread_mutexattr_t * attr, * ------------------------------------------------------ */ { - int result = 0; + int result; if ((attr != NULL && *attr != NULL) && (pshared != NULL)) { *pshared = (*attr)->pshared; + result = 0; } else { - *pshared = PTHREAD_PROCESS_PRIVATE; result = EINVAL; } -- cgit v1.2.3