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

This commit is contained in:
SeliverWang 2024-08-25 10:18:57 +08:00 committed by Meco Man
parent 564ca848f4
commit f7f0afe03e
1 changed files with 2 additions and 0 deletions

View File

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