Merge branch 'issue-2058' into 'main'

win32: Check and avoid using TLS index 0

Closes #2058

See merge request GNOME/glib!2148
This commit is contained in:
Philip Withnall
2021-07-08 11:27:17 +00:00

View File

@@ -319,7 +319,17 @@ g_private_get_impl (GPrivate *key)
impl = TlsAlloc ();
if (impl == TLS_OUT_OF_INDEXES)
if G_UNLIKELY (impl == 0)
{
/* Ignore TLS index 0 temporarily (as 0 is the indicator that we
* haven't allocated TLS yet) and alloc again;
* See https://gitlab.gnome.org/GNOME/glib/-/issues/2058 */
DWORD impl2 = TlsAlloc ();
TlsFree (impl);
impl = impl2;
}
if (impl == TLS_OUT_OF_INDEXES || impl == 0)
g_thread_abort (0, "TlsAlloc");
if (key->notify != NULL)