Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Diff of /sem_getvalue.c [1beb00] .. [9e61bc] Maximize Restore

  Switch to side-by-side view

--- a/sem_getvalue.c
+++ b/sem_getvalue.c
@@ -90,6 +90,15 @@
 
       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;