[crypt32 2/3] Bail-out on registry errors and return FALSE

Paul Vriens Paul.Vriens at xs4all.nl
Thu Sep 7 08:08:01 CDT 2006


Hi,

Bail out when a registry error occurs, there is no need to do more registry
stuff as that will most likely fail (as well). Testing shows that
CryptRegisterOIDFunction return FALSE on registry errors.

Changelog
  Bail-out on registry errors and return FALSE

Cheers,

Paul.

---
 dlls/crypt32/oid.c |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/dlls/crypt32/oid.c b/dlls/crypt32/oid.c
index c88d85f..6195ed4 100644
--- a/dlls/crypt32/oid.c
+++ b/dlls/crypt32/oid.c
@@ -470,25 +470,28 @@ BOOL WINAPI CryptRegisterOIDFunction(DWO
     r = RegCreateKeyA(HKEY_LOCAL_MACHINE, szKey, &hKey);
     CryptMemFree(szKey);
 
-    /* Testing on native shows that registry errors are reported */
-    if(r != ERROR_SUCCESS)
-    {
-        SetLastError(r);
-        return FALSE;
-    }
+    if (r != ERROR_SUCCESS) goto error_close_key;
 
     /* write the values */
     if (pszOverrideFuncName)
     {
         r = RegSetValueExA(hKey, "FuncName", 0, REG_SZ,
              (const BYTE*)pszOverrideFuncName, lstrlenA(pszOverrideFuncName) + 1);
-        if (r != ERROR_SUCCESS) SetLastError(r);
+        if (r != ERROR_SUCCESS) goto error_close_key;
     }
     r = RegSetValueExW(hKey, DllW, 0, REG_SZ, (const BYTE*) pwszDll,
          (lstrlenW(pwszDll) + 1) * sizeof (WCHAR));
-    if (r != ERROR_SUCCESS) SetLastError(r);
+
+error_close_key:
 
     RegCloseKey(hKey);
+
+    if (r != ERROR_SUCCESS) 
+    {
+        SetLastError(r);
+        return FALSE;
+    }
+
     return TRUE;
 }
 
-- 
1.4.2




More information about the wine-patches mailing list