mirror of
https://github.com/apache/nuttx.git
synced 2026-10-15 02:00:16 +00:00
nuttx/tls:Setting the candidtate index to null prevents dangling pointers.
Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
This commit is contained in:
parent
8ffde7cf16
commit
5334c065b4
2 changed files with 4 additions and 2 deletions
|
|
@ -68,13 +68,14 @@ void tls_destruct(void)
|
|||
if (tlsset & mask)
|
||||
{
|
||||
tls_elem_ptr = (FAR void *)tls->tl_elem[candidate];
|
||||
tls->tl_elem[candidate] = 0;
|
||||
destructor = info->ta_tlsdtor[candidate];
|
||||
if (tls_elem_ptr && destructor)
|
||||
{
|
||||
destructor(tls_elem_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
tls->tl_elem[candidate] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -114,12 +114,13 @@ void task_tls_destruct(void)
|
|||
if ((g_tlsset & mask) != 0)
|
||||
{
|
||||
elem = info->ta_telem[candidate];
|
||||
info->ta_telem[candidate] = 0;
|
||||
dtor = g_tlsdtor[candidate];
|
||||
if (dtor != NULL && elem != 0)
|
||||
{
|
||||
dtor((void *)elem);
|
||||
}
|
||||
|
||||
info->ta_telem[candidate] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue