summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--barrier.c16
-rw-r--r--condvar.c3
-rw-r--r--mutex.c8
4 files changed, 20 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index 4786fb2..7e2b920 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,17 @@
2001-07-18 Ross Johnson <rpj@setup1.ise.canberra.edu.au>
+ Contributed by - "Scott McCaskill" <scott@magruder.org>
+
* mutex.c (pthread_mutexattr_init): Return ENOMEM
immediately and don't dereference the NULL pointer
if calloc fails.
- - "Scott McCaskill" <scott@magruder.org>
+ (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.
2001-07-10 Ross Johnson <rpj@setup1.ise.canberra.edu.au>
diff --git a/barrier.c b/barrier.c
index fa52cbf..3cfa66f 100644
--- a/barrier.c
+++ b/barrier.c
@@ -221,13 +221,14 @@ pthread_barrierattr_init (pthread_barrierattr_t * attr)
{
result = ENOMEM;
}
-
- ba->pshared = PTHREAD_PROCESS_PRIVATE;
-
+ else
+ {
+ ba->pshared = PTHREAD_PROCESS_PRIVATE;
+ }
+
*attr = ba;
-
+
return (result);
-
} /* pthread_barrierattr_init */
@@ -270,12 +271,9 @@ pthread_barrierattr_destroy (pthread_barrierattr_t * attr)
*attr = NULL;
free (ba);
-
- result = 0;
}
return (result);
-
} /* pthread_barrierattr_destroy */
@@ -330,12 +328,10 @@ pthread_barrierattr_getpshared (const pthread_barrierattr_t * attr,
}
else
{
- *pshared = PTHREAD_PROCESS_PRIVATE;
result = EINVAL;
}
return (result);
-
} /* pthread_barrierattr_getpshared */
diff --git a/condvar.c b/condvar.c
index 55f0960..15f2e68 100644
--- a/condvar.c
+++ b/condvar.c
@@ -338,7 +338,7 @@ pthread_condattr_getpshared (const pthread_condattr_t * attr, int *pshared)
*
* RESULTS
* 0 successfully retrieved attribute,
- * EINVAL 'attr' is invalid,
+ * EINVAL 'attr' or 'pshared' is invalid,
*
* ------------------------------------------------------
*/
@@ -352,7 +352,6 @@ pthread_condattr_getpshared (const pthread_condattr_t * attr, int *pshared)
}
else
{
- *pshared = PTHREAD_PROCESS_PRIVATE;
result = EINVAL;
}
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;
}