mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-11 20:06:18 +01:00
win32: Check and avoid using TLS index 0
Zero is a valid TLS index so it needs to be checked. It’s also the integer used to indicate that no TLS has been allocated yet, so it can’t be used as a TLS identifier. Incorporates changes from Philip Withnall. Fixes: #2058
This commit is contained in:
parent
71edc3ffe1
commit
3364e02041
@ -319,7 +319,17 @@ g_private_get_impl (GPrivate *key)
|
|||||||
|
|
||||||
impl = TlsAlloc ();
|
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");
|
g_thread_abort (0, "TlsAlloc");
|
||||||
|
|
||||||
if (key->notify != NULL)
|
if (key->notify != NULL)
|
||||||
|
Loading…
Reference in New Issue
Block a user