From 08d8a5ea259cd93f3f0fae3d467cd4524b550abd Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Sun, 24 May 2009 23:16:21 +0200 Subject: [PATCH] urlmon: Use TLS_OUT_OF_INDEXES as invalid TLS value. --- dlls/urlmon/urlmon_main.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/dlls/urlmon/urlmon_main.c b/dlls/urlmon/urlmon_main.c index 3203753f923..6e51db56b98 100644 --- a/dlls/urlmon/urlmon_main.c +++ b/dlls/urlmon/urlmon_main.c @@ -36,7 +36,7 @@ LONG URLMON_refCount = 0; HINSTANCE URLMON_hInstance = 0; static HMODULE hCabinet = NULL; -static DWORD urlmon_tls; +static DWORD urlmon_tls = TLS_OUT_OF_INDEXES; static void init_session(BOOL); @@ -56,9 +56,12 @@ tls_data_t *get_tls_data(void) { tls_data_t *data; - if(!urlmon_tls) { + if(urlmon_tls == TLS_OUT_OF_INDEXES) { DWORD tls = TlsAlloc(); - tls = InterlockedCompareExchange((LONG*)&urlmon_tls, tls, 0); + if(tls == TLS_OUT_OF_INDEXES) + return NULL; + + tls = InterlockedCompareExchange((LONG*)&urlmon_tls, tls, TLS_OUT_OF_INDEXES); if(tls != urlmon_tls) TlsFree(tls); } @@ -83,7 +86,7 @@ static void free_tls_list(void) { tls_data_t *data; - if(!urlmon_tls) + if(urlmon_tls == TLS_OUT_OF_INDEXES) return; while(!list_empty(&tls_list)) { @@ -99,7 +102,7 @@ static void detach_thread(void) { tls_data_t *data; - if(!urlmon_tls) + if(urlmon_tls == TLS_OUT_OF_INDEXES) return; data = TlsGetValue(urlmon_tls);