Test whether passed index is valid in TlsFree

Dmitry Timoshkov dmitry at baikal.ru
Thu Nov 27 07:33:18 CST 2003


Hello,

currently TlsFree(0xFFFFFFFF) crashes. This patch adds
a sanity check for the passed index value.

Changelog:
    Dmitry Timoshkov <dmitry at codeweavers.com>
    Test whether passed index is valid in TlsFree.

--- cvs/hq/wine/dlls/kernel/process.c	Tue Nov 25 12:17:42 2003
+++ wine/dlls/kernel/process.c	Thu Nov 27 21:16:30 2003
@@ -1910,6 +1910,12 @@ BOOL WINAPI TlsFree(
 {
     BOOL ret;
 
+    if (index >= NtCurrentTeb()->Peb->TlsBitmap->SizeOfBitMap)
+    {
+        SetLastError( ERROR_INVALID_PARAMETER );
+        return FALSE;
+    }
+
     RtlAcquirePebLock();
     ret = RtlAreBitsSet( NtCurrentTeb()->Peb->TlsBitmap, index, 1 );
     if (ret)






More information about the wine-patches mailing list