[PATCH 1/2] kernel32/tests: Add a test case for calling TlsFree on a freed index. [try 3]
Reece Dunn
msclrhd at googlemail.com
Tue Mar 2 16:07: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.
try 3: Don't unnecessarily set the ret value to FALSE, as it will be
FALSE if SetLastError is set to ERROR_INVALID_PARAMETER.
- Reece
-------------- next part --------------
From e5d75427e3e2580f3e129d76efc429b83d431e0b Mon Sep 17 00:00:00 2001
From: Reece Dunn <msclrhd at gmail.com>
Date: Tue, 2 Mar 2010 21:29:48 +0000
Subject: [PATCH 1/2] kernel32/tests: Add a test case for calling TlsFree on a freed index.
---
dlls/kernel32/process.c | 2 +-
dlls/kernel32/tests/thread.c | 12 +++++++++++-
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c
index 1ef3e46..d9d4520 100644
--- a/dlls/kernel32/process.c
+++ b/dlls/kernel32/process.c
@@ -2496,7 +2496,7 @@ BOOL WINAPI TlsFree( DWORD index )
if (ret) NtSetInformationThread( GetCurrentThread(), ThreadZeroTlsCell, &index, sizeof(index) );
else 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