Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.8, 0.8.1, and 0.8.2

shellext: fix registry handle leak in GetCMenuTranslation()

Changeset 13986b88df8c

Parent 4af261cfb396

by Adrian Buehlmann

Changes to one file · Browse files at 13986b88df8c Showing diff from parent 4af261cfb396 Diff from another changeset...

 
149
150
151
152
153
 
 
 
 
154
155
156
 
 
 
157
158
159
160
 
 
 
 
 
161
162
163
164
165
 
 
166
167
168
 
149
150
151
 
 
152
153
154
155
156
 
 
157
158
159
160
 
 
 
161
162
163
164
165
166
 
 
 
 
167
168
169
170
171
@@ -149,20 +149,23 @@
  LONG rv = RegOpenKeyExA(   HKEY_CURRENT_USER, subkey.c_str(), 0, KEY_READ, &hkey);   - if (rv != ERROR_SUCCESS || hkey == 0) - return; + if (rv == ERROR_SUCCESS && hkey) + { + BYTE Data[MAX_PATH] = ""; + DWORD cbData = MAX_PATH * sizeof(BYTE);   - BYTE Data[MAX_PATH] = ""; - DWORD cbData = MAX_PATH * sizeof(BYTE); + rv = RegQueryValueExA(hkey, "menuText", 0, 0, Data, &cbData); + if (rv == ERROR_SUCCESS) + menuText = reinterpret_cast<const char*>(&Data);   - rv = RegQueryValueExA(hkey, "menuText", 0, 0, Data, &cbData); - if (rv == ERROR_SUCCESS) - menuText = reinterpret_cast<const char*>(&Data); + cbData = MAX_PATH * sizeof(BYTE); + rv = RegQueryValueExA(hkey, "helpText", 0, 0, Data, &cbData); + if (rv == ERROR_SUCCESS) + helpText = reinterpret_cast<const char*>(&Data); + }   - cbData = MAX_PATH * sizeof(BYTE); - rv = RegQueryValueExA(hkey, "helpText", 0, 0, Data, &cbData); - if (rv == ERROR_SUCCESS) - helpText = reinterpret_cast<const char*>(&Data); + if (hkey) + RegCloseKey(hkey);  }