kernel32/tests: Add a test case for calling TlsFree on a freed index.
authorReece Dunn <msclrhd@gmail.com>
Tue, 2 Mar 2010 21:29:48 +0000 (21:29 +0000)
committerAlexandre Julliard <julliard@winehq.org>
Wed, 3 Mar 2010 10:49:35 +0000 (11:49 +0100)
dlls/kernel32/process.c
dlls/kernel32/tests/thread.c

index 1ef3e464eb195c2b6ff2d85019cd17ead904ae16..d9d452038a7bb40eaca29f7b880e43e227b5335a 100644 (file)
@@ -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;
 }
 
 
index 83d13c56e1e75fd69fc077c194eb70ce35f97624..afa67592a4aa90d6e18d66f59fa74a1e0654c57a 100644 (file)
@@ -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);