summaryrefslogtreecommitdiff
path: root/sem_post_multiple.c
diff options
context:
space:
mode:
Diffstat (limited to 'sem_post_multiple.c')
-rw-r--r--sem_post_multiple.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/sem_post_multiple.c b/sem_post_multiple.c
index fa950bd..3d1e4ef 100644
--- a/sem_post_multiple.c
+++ b/sem_post_multiple.c
@@ -86,6 +86,15 @@ sem_post_multiple (sem_t * sem, int count)
}
else if ((result = pthread_mutex_lock (&s->lock)) == 0)
{
+ /* See sem_destroy.c
+ */
+ if (*sem == NULL)
+ {
+ (void) pthread_mutex_unlock (&s->lock);
+ result = EINVAL;
+ return -1;
+ }
+
if (s->value <= (SEM_VALUE_MAX - count))
{
waiters = -s->value;