Octavian Voicu : msi: Fix crash when calling MsiGetActiveDatabase with invalid remote handle.

Alexandre Julliard julliard at winehq.org
Mon Apr 19 11:51:17 CDT 2010


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

Author: Octavian Voicu <octavian.voicu at gmail.com>
Date:   Mon Apr 19 12:49:40 2010 +0300

msi: Fix crash when calling MsiGetActiveDatabase with invalid remote handle.

---

 dlls/msi/package.c |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/dlls/msi/package.c b/dlls/msi/package.c
index b1741ae..71346f4 100644
--- a/dlls/msi/package.c
+++ b/dlls/msi/package.c
@@ -1357,6 +1357,7 @@ MSIHANDLE WINAPI MsiGetActiveDatabase(MSIHANDLE hInstall)
 {
     MSIPACKAGE *package;
     MSIHANDLE handle = 0;
+    IUnknown *remote_unk;
     IWineMsiRemotePackage *remote_package;
 
     TRACE("(%d)\n",hInstall);
@@ -1367,10 +1368,19 @@ MSIHANDLE WINAPI MsiGetActiveDatabase(MSIHANDLE hInstall)
         handle = alloc_msihandle( &package->db->hdr );
         msiobj_release( &package->hdr );
     }
-    else if ((remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall )))
+    else if ((remote_unk = msi_get_remote(hInstall)))
     {
-        IWineMsiRemotePackage_GetActiveDatabase(remote_package, &handle);
-        IWineMsiRemotePackage_Release(remote_package);
+        if (IUnknown_QueryInterface(remote_unk, &IID_IWineMsiRemotePackage,
+                                        (LPVOID *)&remote_package) == S_OK)
+        {
+            IWineMsiRemotePackage_GetActiveDatabase(remote_package, &handle);
+            IWineMsiRemotePackage_Release(remote_package);
+        }
+        else
+        {
+            WARN("remote handle %d is not a package\n", hInstall);
+        }
+        IUnknown_Release(remote_unk);
     }
 
     return handle;




More information about the wine-cvs mailing list