wordpad: do not try to close uninitialized handles

James Hawkins truiken at gmail.com
Sun Oct 12 12:52:15 CDT 2008


On Sun, Oct 12, 2008 at 6:09 AM, Andrey Turkin <andrey.turkin at gmail.com> wrote:
>
> Fix some functions where CloseHandle was called not matter if previous
> open succeeded or not.
>

     HKEY hKey;

     DWORD size = sizeof(RECT);

+    BOOL succeeded = FALSE;



-    if(registry_get_handle(&hKey, 0, key_options) != ERROR_SUCCESS ||

-       RegQueryValueExW(hKey, var_framerect, 0, NULL, (LPBYTE)rc, &size) !=

-       ERROR_SUCCESS || size != sizeof(RECT))

+    if(registry_get_handle(&hKey, 0, key_options) == ERROR_SUCCESS)

+    {

+        if (RegQueryValueExW(hKey, var_framerect, 0, NULL,
(LPBYTE)rc, &size) ==

+           ERROR_SUCCESS && size == sizeof(RECT))

+        {

+            succeeded = TRUE;

+        }

+

+        RegCloseKey(hKey);

+    }

+    if (!succeeded)

     {

All of these changes would be a lot cleaner if you just initialize hKey to 0.

-- 
James Hawkins



More information about the wine-devel mailing list