On Sun, Apr 18, 2010 at 11:07 PM, Mike Kaplinskiy <mike.kaplins...@gmail.com> wrote: > I'm not much of a COM expert, but from what it looks like in order to > tell if an interface is really the interface you expect, the right way > would be to QueryInterface it (idea from > http://source.winehq.org/source/dlls/msxml3/domdoc.c#L1499 ).
Good point! I did think of QueryInterface at some point, but forgot about it. I attached the new patch. If there are no further suggestions, I'll post it on wine-patches. Octavian
From 8b7694819e5d74886425f46f53f26c678704c592 Mon Sep 17 00:00:00 2001 From: Octavian Voicu <octavian.vo...@gmail.com> Date: Sun, 18 Apr 2010 22:15:15 +0300 Subject: [PATCH] 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; -- 1.6.3.3