]> granicus.if.org Git - icu/commitdiff
ICU-12908 getTZKeyName in common/wintz.cpp leaks registry handle
authorJeff Genovy <29107334+jefgen@users.noreply.github.com>
Fri, 13 Jan 2017 01:48:47 +0000 (01:48 +0000)
committerJeff Genovy <29107334+jefgen@users.noreply.github.com>
Fri, 13 Jan 2017 01:48:47 +0000 (01:48 +0000)
We should only call RegCloseKey if we were actually able to open the key.
(The value of hkey isn't explicitly initialized, so we could possibly be calling RegCloseKey with random data.)

X-SVN-Rev: 39556

icu4c/source/common/wintz.cpp

index 14fc476040c7ebd52c49f26a8863b81c7180ace0..79526eb80820c5c28e0d9b25379aed266483b0d4 100644 (file)
@@ -165,11 +165,9 @@ static LONG getTZI(const char *winid, TZI *tzi)
                                     NULL,
                                     (LPBYTE)tzi,
                                     &cbData);
-
+        RegCloseKey(hkey);
     }
 
-    RegCloseKey(hkey);
-
     return result;
 }
 
@@ -187,11 +185,9 @@ static LONG getSTDName(const char *winid, char *regStdName, int32_t length) {
                                     NULL,
                                     (LPBYTE)regStdName,
                                     &cbData);
-
+        RegCloseKey(hkey);
     }
 
-    RegCloseKey(hkey);
-
     return result;
 }
 
@@ -214,9 +210,9 @@ static LONG getTZKeyName(char* tzKeyName, int32_t length) {
              NULL,
              (LPBYTE)tzKeyName,
              &cbData);
-    }
 
-    RegCloseKey(hkey);
+        RegCloseKey(hkey);
+    }
 
     return result;
 }