Author: akhaldi
Date: Sat Oct 1 21:02:14 2011
New Revision: 53919
URL:
http://svn.reactos.org/svn/reactos?rev=53919&view=rev
Log:
[ADVAPI32]
* Sync CryptEnumProvidersW. Fixes some HKEY leaks.
See issue #6237 for more details.
Modified:
trunk/reactos/dll/win32/advapi32/crypt/crypt.c
Modified: trunk/reactos/dll/win32/advapi32/crypt/crypt.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/crypt/c…
==============================================================================
--- trunk/reactos/dll/win32/advapi32/crypt/crypt.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/advapi32/crypt/crypt.c [iso-8859-1] Sat Oct 1 21:02:14 2011
@@ -1104,6 +1104,7 @@
'P','r','o','v','i','d','e','r',0
};
static const WCHAR typeW[] = {'T','y','p','e',0};
+ BOOL ret;
TRACE("(%d, %p, %d, %p, %p, %p)\n", dwIndex, pdwReserved, dwFlags,
pdwProvType, pszProvName, pcbProvName);
@@ -1125,6 +1126,7 @@
return FALSE;
}
+ ret = TRUE;
if (!pszProvName)
{
DWORD numkeys;
@@ -1136,6 +1138,7 @@
if (!(provNameW = CRYPT_Alloc(*pcbProvName * sizeof(WCHAR))))
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ RegCloseKey(hKey);
return FALSE;
}
@@ -1147,7 +1150,7 @@
if (dwIndex >= numkeys)
{
SetLastError(ERROR_NO_MORE_ITEMS);
- return FALSE;
+ ret = FALSE;
}
} else {
DWORD size = sizeof(DWORD);
@@ -1158,16 +1161,22 @@
if (result)
{
SetLastError(result);
+ RegCloseKey(hKey);
return FALSE;
}
if (RegOpenKeyW(hKey, pszProvName, &subkey))
+ {
+ RegCloseKey(hKey);
return FALSE;
+ }
+
if (RegQueryValueExW(subkey, typeW, NULL, NULL, (BYTE*)pdwProvType, &size))
- return FALSE;
+ ret = FALSE;
+
RegCloseKey(subkey);
}
RegCloseKey(hKey);
- return TRUE;
+ return ret;
}
/******************************************************************************