From bc9005968a4d21822fbb0932842507afba0d41d7 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Tue, 11 Nov 2014 19:23:35 +0100 Subject: [PATCH] Windows: Avoid calling RegCloseKey on an invalid handle. --- src/Common/Dlgcode.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c index 42e52468..e0fe6831 100644 --- a/src/Common/Dlgcode.c +++ b/src/Common/Dlgcode.c @@ -2409,14 +2409,15 @@ void InitApp (HINSTANCE hInstance, char *lpszCommandLine) DWORD val = 0, size = sizeof(val); HKEY hkey; - if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\Atapi\\Parameters", 0, KEY_READ, &hkey) == ERROR_SUCCESS - && (RegQueryValueEx (hkey, "EnableBigLba", 0, 0, (LPBYTE) &val, &size) != ERROR_SUCCESS - || val != 1)) - + if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\Atapi\\Parameters", 0, KEY_READ, &hkey) == ERROR_SUCCESS) { - Warning ("LARGE_IDE_WARNING_2K_REGISTRY"); + if (RegQueryValueEx (hkey, "EnableBigLba", 0, 0, (LPBYTE) &val, &size) != ERROR_SUCCESS + || val != 1) + { + Warning ("LARGE_IDE_WARNING_2K_REGISTRY"); + } + RegCloseKey (hkey); } - RegCloseKey (hkey); } break;