Browse Source

[fix] return "EINVAL" if "count" is zero.

liuxianliang 3 years ago
parent
commit
6dd6929b8e
1 changed files with 2 additions and 0 deletions
  1. 2 0
      components/libc/posix/pthreads/pthread_barrier.c

+ 2 - 0
components/libc/posix/pthreads/pthread_barrier.c

@@ -72,6 +72,8 @@ int pthread_barrier_init(pthread_barrier_t           *barrier,
         return EINVAL;
     if (attr && (*attr != PTHREAD_PROCESS_PRIVATE))
         return EINVAL;
+    if (count == 0)
+        return EINVAL;
 
     barrier->count = count;
     pthread_cond_init(&(barrier->cond), NULL);