[PATCH 2/2] crypt32: Fix CryptFreeTls when calling with a freed index. [try 2]
Reece Dunn
msclrhd at googlemail.com
Tue Mar 2 15:17:29 CST 2010
Hi,
GetLastError returned by CryptFreeTls is a HRESULT error code, whereas
with TlsFree it is a Win32 error code, so convert it to a HRESULT
error code when TlsFree fails.
try 2: resend of this patch to complete the series after updating patch 1.
- Reece
-------------- next part --------------
From e5671a2b7c6035009bfd90934f4ccde40e9276c3 Mon Sep 17 00:00:00 2001
From: Reece Dunn <msclrhd at gmail.com>
Date: Tue, 2 Mar 2010 20:29:42 +0000
Subject: [PATCH 2/2] crypt32: Fix CryptFreeTls when calling with a freed index.
---
dlls/crypt32/main.c | 9 ++++++++-
dlls/crypt32/tests/main.c | 6 ++----
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/dlls/crypt32/main.c b/dlls/crypt32/main.c
index 1a5972f..3e2702c 100644
--- a/dlls/crypt32/main.c
+++ b/dlls/crypt32/main.c
@@ -161,8 +161,15 @@ BOOL WINAPI I_CryptSetTls(DWORD dwTlsIndex, LPVOID lpTlsValue)
BOOL WINAPI I_CryptFreeTls(DWORD dwTlsIndex, DWORD unknown)
{
+ BOOL ret;
+
TRACE("(%d, %d)\n", dwTlsIndex, unknown);
- return TlsFree(dwTlsIndex);
+
+ ret = TlsFree(dwTlsIndex);
+ if (!ret)
+ SetLastError(HRESULT_FROM_WIN32(GetLastError()));
+
+ return ret;
}
BOOL WINAPI I_CryptGetOssGlobal(DWORD x)
diff --git a/dlls/crypt32/tests/main.c b/dlls/crypt32/tests/main.c
index 9b622bb..7c11e8e 100644
--- a/dlls/crypt32/tests/main.c
+++ b/dlls/crypt32/tests/main.c
@@ -254,10 +254,8 @@ static void test_cryptTls(void)
ret = pI_CryptFreeTls(index, 0);
ok(ret, "I_CryptFreeTls failed: %08x\n", GetLastError());
ret = pI_CryptFreeTls(index, 0);
- /* Not sure if this fails because TlsFree should fail, so leave as
- * todo for now.
- */
- todo_wine ok(!ret && GetLastError() == E_INVALIDARG,
+ ok(!ret, "I_CryptFreeTls succeeded\n");
+ ok(GetLastError() == E_INVALIDARG,
"Expected E_INVALIDARG, got %08x\n", GetLastError());
}
/* Similar pass, check I_CryptDetachTls */
--
1.6.3.3
More information about the wine-patches
mailing list