From http://www.jwz.org/xscreensaver/xscreensaver-5.34.tar.gz
[xscreensaver] / utils / thread_util.c
index bccb74626d3ccbe4caee8a4e80f2b7e22fc02217..6852a2138fa2e64f8d13700a4f122a39aa688976 100644 (file)
@@ -694,18 +694,16 @@ static void _unlock_and_destroy(struct threadpool *self)
 
        PTHREAD_VERIFY(pthread_mutex_unlock(&self->mutex));
 
-       if(!threads)
-               return;
-
+       if(threads)
        {
                unsigned i, count = _threadpool_count_parallel(self);
                for(i = 0; i != count; ++i)
                        PTHREAD_VERIFY(pthread_join(threads[i], NULL));
-       }
 
-       free(threads);
-       PTHREAD_VERIFY(pthread_cond_destroy(&self->cond));
-       PTHREAD_VERIFY(pthread_mutex_destroy(&self->mutex));
+               free(threads);
+               PTHREAD_VERIFY(pthread_cond_destroy(&self->cond));
+               PTHREAD_VERIFY(pthread_mutex_destroy(&self->mutex));
+       }
 
        _serial_destroy(self);
 }