On Sun, Oct 12, 2008 at 6:09 AM, Andrey Turkin andrey.turkin@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.