Huw Davies : msi: Fix a registry key leak.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Jul 15 09:51:24 CDT 2015


Module: wine
Branch: master
Commit: 4a992fec01ab142063da2fc2f66b2a58c8845c36
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=4a992fec01ab142063da2fc2f66b2a58c8845c36

Author: Huw Davies <huw at codeweavers.com>
Date:   Wed Jul 15 12:32:18 2015 +0100

msi: Fix a registry key leak.

---

 dlls/msi/action.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/dlls/msi/action.c b/dlls/msi/action.c
index 88bb1bb..22e97a7 100644
--- a/dlls/msi/action.c
+++ b/dlls/msi/action.c
@@ -2973,13 +2973,17 @@ static void delete_key( const MSICOMPONENT *comp, HKEY root, const WCHAR *path )
     access |= get_registry_view( comp );
 
     if (!(subkey = strdupW( path ))) return;
-    for (;;)
+    do
     {
-        if ((p = strrchrW( subkey, '\\' ))) *p = 0;
-        hkey = open_key( comp, root, subkey, FALSE );
-        if (!hkey) break;
-        if (p && p[1])
+        if ((p = strrchrW( subkey, '\\' )))
+        {
+            *p = 0;
+            if (!p[1]) continue; /* trailing backslash */
+            hkey = open_key( comp, root, subkey, FALSE );
+            if (!hkey) break;
             res = RegDeleteKeyExW( hkey, p + 1, access, 0 );
+            RegCloseKey( hkey );
+        }
         else
             res = RegDeleteKeyExW( root, subkey, access, 0 );
         if (res)
@@ -2987,9 +2991,7 @@ static void delete_key( const MSICOMPONENT *comp, HKEY root, const WCHAR *path )
             TRACE("failed to delete key %s (%d)\n", debugstr_w(subkey), res);
             break;
         }
-        if (p && p[1]) RegCloseKey( hkey );
-        else break;
-    }
+    } while (p);
     msi_free( subkey );
 }
 




More information about the wine-cvs mailing list