Skip to content

Commit 277325c

Browse files
committed
[pthreads] fix pthread_cond_init issue when attr is NULL.
1 parent fe2047b commit 277325c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

components/pthreads/pthread_cond.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,11 @@ int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
9898

9999
rt_snprintf(cond_name, sizeof(cond_name), "cond%02d", cond_num++);
100100

101-
cond->attr = *attr;
101+
if (attr == RT_NULL) /* use default value */
102+
cond->attr = PTHREAD_PROCESS_PRIVATE;
103+
else
104+
cond->attr = *attr;
105+
102106
result = rt_sem_init(&cond->sem, cond_name, 0, RT_IPC_FLAG_FIFO);
103107
if (result != RT_EOK)
104108
return EINVAL;

0 commit comments

Comments
 (0)