summaryrefslogtreecommitdiff
path: root/sem_getvalue.c
diff options
context:
space:
mode:
Diffstat (limited to 'sem_getvalue.c')
-rw-r--r--sem_getvalue.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/sem_getvalue.c b/sem_getvalue.c
index ae13ef9..baafb02 100644
--- a/sem_getvalue.c
+++ b/sem_getvalue.c
@@ -90,6 +90,15 @@ sem_getvalue (sem_t * sem, int *sval)
if ((result = pthread_mutex_lock(&s->lock)) == 0)
{
+ /* See sem_destroy.c
+ */
+ if (*sem == NULL)
+ {
+ (void) pthread_mutex_unlock (&s->lock);
+ errno = EINVAL;
+ return -1;
+ }
+
value = s->value;
(void) pthread_mutex_unlock(&s->lock);
*sval = value;