From 40f9b33eb7b2a7826bb1171794d39c20f1be52aa Mon Sep 17 00:00:00 2001 From: Jeff Genovy <29107334+jefgen@users.noreply.github.com> Date: Fri, 13 Jan 2017 01:48:47 +0000 Subject: [PATCH] ICU-12908 getTZKeyName in common/wintz.cpp leaks registry handle 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 | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/icu4c/source/common/wintz.cpp b/icu4c/source/common/wintz.cpp index 14fc476040c..79526eb8082 100644 --- a/icu4c/source/common/wintz.cpp +++ b/icu4c/source/common/wintz.cpp @@ -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; } -- 2.50.1