From 55dbeff93ce46bfba9beaea7b9a67ba7fcd6df88 Mon Sep 17 00:00:00 2001
From: Paul Gofman <pgofman@codeweavers.com>
Date: Thu, 23 Apr 2020 19:44:32 +0300
Subject: [PATCH] kernelbase: Don't use PEB lock for FLS data.

---
 dlls/kernelbase/thread.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/dlls/kernelbase/thread.c b/dlls/kernelbase/thread.c
index 4409f120491..0ba67e1b6c9 100644
--- a/dlls/kernelbase/thread.c
+++ b/dlls/kernelbase/thread.c
@@ -1108,7 +1108,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH FlsAlloc( PFLS_CALLBACK_FUNCTION callback )
     DWORD index;
     PEB * const peb = NtCurrentTeb()->Peb;
 
-    RtlAcquirePebLock();
+    lock_fls_section();
     if (!peb->FlsCallback)
     {
         SetLastError( ERROR_NOT_ENOUGH_MEMORY );
@@ -1133,7 +1133,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH FlsAlloc( PFLS_CALLBACK_FUNCTION callback )
         }
         else SetLastError( ERROR_NO_MORE_ITEMS );
     }
-    RtlReleasePebLock();
+    unlock_fls_section();
     return index;
 }
 
@@ -1145,7 +1145,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH FlsFree( DWORD index )
 {
     BOOL ret;
 
-    RtlAcquirePebLock();
+    lock_fls_section();
     ret = RtlAreBitsSet( NtCurrentTeb()->Peb->FlsBitmap, index, 1 );
     if (ret) RtlClearBits( NtCurrentTeb()->Peb->FlsBitmap, index, 1 );
     if (ret)
@@ -1155,7 +1155,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH FlsFree( DWORD index )
         if (NtCurrentTeb()->FlsSlots) *fls_addr_from_index(NtCurrentTeb()->FlsSlots, index) = NULL;
     }
     else SetLastError( ERROR_INVALID_PARAMETER );
-    RtlReleasePebLock();
+    unlock_fls_section();
     return ret;
 }
 
-- 
2.25.3

