On Fri, 7 Aug 2026 08:53:51 GMT, Matthias Baesken <[email protected]> wrote:
> There is a RegOpenKeyExA call present, but we do not close the handle. This > should be changed. > The MS docu says > https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regopenkeyexa > 'A pointer to a variable that receives a handle to the opened key. If the key > is not one of the predefined registry keys, call the > [RegCloseKey](https://learn.microsoft.com/en-us/windows/desktop/api/winreg/nf-winreg-regclosekey) > function after you have finished using the handle.' > And in this coding we call > `LONG lRet = ::RegOpenKeyExA(hRootKey, lpszSubKey, 0, KEY_ALL_ACCESS, &hKey); > ` > with a non_NULL `lpszSubKey `so the RegCloseKey has to be done. > > Also fixed a typo while at it. > > --------- > - [x] I confirm that I make this contribution in accordance with the [OpenJDK > Interim AI Policy](https://openjdk.org/legal/ai). Same here in our Hotspot codebase https://github.com/openjdk/jdk/blob/1a0ce5d6f405b7b976598a1c301ba3972166cfb2/src/hotspot/os/windows/os_windows.cpp#L4271 ` if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, subKey, 0, KEY_READ, &hKey) != ERROR_SUCCESS) {` We use HKEY_LOCAL_MACHINE (which is one of the special predefined keys HKEY_CLASSES_ROOT HKEY_CURRENT_CONFIG HKEY_CURRENT_USER **HKEY_LOCAL_MACHINE** HKEY_USERS ). But we still call ` RegCloseKey(hKey);` a few lines later (subkey is non-null here too). ------------- PR Comment: https://git.openjdk.org/jdk/pull/32249#issuecomment-5240687322
