[PATCH 1/2] kernel32/tests: Add a test case for calling TlsFree on a freed index. [try 2]
Reece Dunn
msclrhd at googlemail.com
Tue Mar 2 15:17:20 CST 2010
Hi,
TlsFree should return FALSE if there wasn't a TLS slot of the
specified index allocated, as well as returning
ERROR_INVALID_PARAMETER.
try 2: SetLastError to a garbage value to test that last error is
actually changing, as noted by Nikolay Sivov.
- Reece
-------------- next part --------------
From ae9df3ac80c36369d9a7fb1ff6b764ae9045d7ea Mon Sep 17 00:00:00 2001
From: Reece Dunn <msclrhd at gmail.com>
Date: Tue, 2 Mar 2010 20:28:37 +0000
Subject: [PATCH 1/2] kernel32/tests: Add a test case for calling TlsFree on a freed index.
---
dlls/kernel32/process.c | 8 ++++++--
dlls/kernel32/tests/thread.c | 12 +++++++++++-
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c
index 1ef3e46..e6905fb 100644
--- a/dlls/kernel32/process.c
+++ b/dlls/kernel32/process.c
@@ -2494,9 +2494,13 @@ BOOL WINAPI TlsFree( DWORD index )
if (ret) RtlClearBits( NtCurrentTeb()->Peb->TlsBitmap, index, 1 );
}
if (ret) NtSetInformationThread( GetCurrentThread(), ThreadZeroTlsCell, &index, sizeof(index) );
- else SetLastError( ERROR_INVALID_PARAMETER );
+ else
+ {
+ ret = FALSE;
+ SetLastError( ERROR_INVALID_PARAMETER );
+ }
RtlReleasePebLock();
- return TRUE;
+ return ret;
}
diff --git a/dlls/kernel32/tests/thread.c b/dlls/kernel32/tests/thread.c
index 83d13c5..afa6759 100644
--- a/dlls/kernel32/tests/thread.c
+++ b/dlls/kernel32/tests/thread.c
@@ -421,7 +421,17 @@ static VOID test_CreateThread_basic(void)
"Thread did not execute successfully\n");
ok(CloseHandle(thread[i])!=0,"CloseHandle failed\n");
}
- ok(TlsFree(tlsIndex)!=0,"TlsFree failed\n");
+
+ SetLastError(0xCAFEF00D);
+ ok(TlsFree(tlsIndex)!=0,"TlsFree failed: %08x\n", GetLastError());
+ ok(GetLastError()==0xCAFEF00D,
+ "GetLastError: expected 0xCAFEF00D, got %08x\n", GetLastError());
+
+ /* Test freeing an already freed TLS index */
+ SetLastError(0xCAFEF00D);
+ ok(TlsFree(tlsIndex)==0,"TlsFree succeeded\n");
+ ok(GetLastError()==ERROR_INVALID_PARAMETER,
+ "GetLastError: expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError());
/* Test how passing NULL as a pointer to threadid works */
SetLastError(0xFACEaBAD);
--
1.6.3.3
More information about the wine-patches
mailing list