Browse Source

修复TLS申请内存后没有初始化问题

SeliverWang 8 tháng trước cách đây
mục cha
commit
f7f0afe03e
1 tập tin đã thay đổi với 2 bổ sung0 xóa
  1. 2 0
      components/libc/posix/pthreads/pthread_tls.c

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

@@ -55,6 +55,8 @@ int pthread_setspecific(pthread_key_t key, const void *value)
     if (ptd->tls == NULL)
     {
         ptd->tls = (void**)rt_malloc(sizeof(void*) * PTHREAD_KEY_MAX);
+
+        rt_memset(ptd->tls, 0, sizeof(void*) * PTHREAD_KEY_MAX);
     }
 
     if ((key < PTHREAD_KEY_MAX) && _thread_keys[key].is_used)