Clear the TLS pointer after running its destructor callback

This commit is contained in:
Chris Robinson
2018-06-06 23:10:37 -07:00
parent 72e4b60374
commit bd9c6989c2
+5 -1
View File
@@ -428,7 +428,11 @@ void althrd_thread_detach(void)
{
void *ptr = altss_get(TlsDestructors.keys[i]);
altss_dtor_t callback = (altss_dtor_t)TlsDestructors.values[i];
if(ptr && callback) callback(ptr);
if(ptr)
{
if(callback) callback(ptr);
altss_set(TlsDestructors.keys[i], NULL);
}
}
UnlockUIntMapRead(&TlsDestructors);
}