-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
5.12.4, 5.13.0
-
None
-
-
64d949207686a0225a78de572548a5361e340ae3 (qt/qtbase/5.12)
qt_current_thread_data_tls_index is created by qt_create_tls() function.
If qt_create_tls() is called by multiple threads at the same time, qt_current_thread_data_tls_index may be created multiple times, and only the last one is saved, the others are leaked.
The code could be changed as follows.
void qt_create_tls()
{
if (qt_current_thread_data_tls_index != TLS_OUT_OF_INDEXES)
return;
static QBasicMutex mutex;
QMutexLocker locker(&mutex);
if (qt_current_thread_data_tls_index != TLS_OUT_OF_INDEXES)
return;
qt_current_thread_data_tls_index = TlsAlloc();
}