[ATL] Close m_hKey in CRegKey destructor and when attaching to a new key (#3764)

This commit is contained in:
He Yang 2021-06-25 03:20:01 +05:30 committed by GitHub
parent aa2697df2d
commit 42e111f26b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1043,6 +1043,7 @@ public:
~CRegKey() throw()
{
Close();
}
void Attach(HKEY hKey) throw()
@ -1359,7 +1360,11 @@ public:
CRegKey& operator=(CRegKey& key) throw()
{
Attach(key.Detach());
if (m_hKey != key.m_hKey)
{
Close();
Attach(key.Detach());
}
return *this;
}