https://git.reactos.org/?p=reactos.git;a=commitdiff;h=42e111f26b96bd3703b44653fe9871f2e6b7e915

commit 42e111f26b96bd3703b44653fe9871f2e6b7e915
Author:     He Yang <[email protected]>
AuthorDate: Fri Jun 25 03:20:01 2021 +0530
Commit:     GitHub <[email protected]>
CommitDate: Thu Jun 24 23:50:01 2021 +0200

    [ATL] Close m_hKey in CRegKey destructor and when attaching to a new key 
(#3764)
---
 sdk/lib/atl/atlbase.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/sdk/lib/atl/atlbase.h b/sdk/lib/atl/atlbase.h
index fa3cf72cd8a..502d7b1ad44 100644
--- a/sdk/lib/atl/atlbase.h
+++ b/sdk/lib/atl/atlbase.h
@@ -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;
     }
 

Reply via email to