ole32: Fix equality check in CommonPrefixWith() for pointer moniker.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2020-01-28 10:32:17 +03:00 committed by Alexandre Julliard
parent 5a93d97268
commit 70f35c65ab
2 changed files with 66 additions and 24 deletions

View File

@ -48,9 +48,10 @@ typedef struct PointerMonikerImpl{
static inline PointerMonikerImpl *impl_from_IMoniker(IMoniker *iface)
{
return CONTAINING_RECORD(iface, PointerMonikerImpl, IMoniker_iface);
return CONTAINING_RECORD(iface, PointerMonikerImpl, IMoniker_iface);
}
static PointerMonikerImpl *unsafe_impl_from_IMoniker(IMoniker *iface);
static HRESULT WINAPI
PointerMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject)
{
@ -58,7 +59,6 @@ PointerMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject)
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppvObject);
/* Perform a sanity check on the parameters.*/
if ( (This==0) || (ppvObject==0) )
return E_INVALIDARG;
@ -337,26 +337,20 @@ PointerMonikerImpl_Enum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoni
/******************************************************************************
* PointerMoniker_IsEqual
******************************************************************************/
static HRESULT WINAPI
PointerMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker)
static HRESULT WINAPI PointerMonikerImpl_IsEqual(IMoniker *iface, IMoniker *other)
{
PointerMonikerImpl *This = impl_from_IMoniker(iface);
DWORD mkSys;
PointerMonikerImpl *moniker = impl_from_IMoniker(iface), *other_moniker;
TRACE("(%p,%p)\n",iface,pmkOtherMoniker);
TRACE("%p, %p.\n", iface, other);
if (pmkOtherMoniker==NULL)
if (!other)
return E_INVALIDARG;
other_moniker = unsafe_impl_from_IMoniker(other);
if (!other_moniker)
return S_FALSE;
IMoniker_IsSystemMoniker(pmkOtherMoniker,&mkSys);
if (mkSys==MKSYS_POINTERMONIKER)
{
PointerMonikerImpl *pOtherMoniker = impl_from_IMoniker(pmkOtherMoniker);
return This->pObject == pOtherMoniker->pObject ? S_OK : S_FALSE;
}
else
return S_FALSE;
return moniker->pObject == other_moniker->pObject ? S_OK : S_FALSE;
}
/******************************************************************************
@ -412,18 +406,20 @@ PointerMonikerImpl_Inverse(IMoniker* iface,IMoniker** ppmk)
/******************************************************************************
* PointerMoniker_CommonPrefixWith
******************************************************************************/
static HRESULT WINAPI
PointerMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther,IMoniker** ppmkPrefix)
static HRESULT WINAPI PointerMonikerImpl_CommonPrefixWith(IMoniker *iface, IMoniker *other, IMoniker **prefix)
{
TRACE("(%p, %p)\n", pmkOther, ppmkPrefix);
TRACE("%p, %p, %p.\n", iface, other, prefix);
*ppmkPrefix = NULL;
if (!prefix || !other)
return E_INVALIDARG;
if (PointerMonikerImpl_IsEqual(iface, pmkOther))
*prefix = NULL;
if (PointerMonikerImpl_IsEqual(iface, other) == S_OK)
{
IMoniker_AddRef(iface);
*ppmkPrefix=iface;
*prefix = iface;
return MK_S_US;
}
@ -539,6 +535,13 @@ static const IMonikerVtbl VT_PointerMonikerImpl =
PointerMonikerImpl_IsSystemMoniker
};
static PointerMonikerImpl *unsafe_impl_from_IMoniker(IMoniker *iface)
{
if (iface->lpVtbl != &VT_PointerMonikerImpl)
return NULL;
return CONTAINING_RECORD(iface, PointerMonikerImpl, IMoniker_iface);
}
/******************************************************************************
* PointerMoniker_Construct (local function)
*******************************************************************************/

View File

@ -2625,7 +2625,7 @@ todo_wine
static void test_pointer_moniker(void)
{
IMoniker *moniker, *inverse;
IMoniker *moniker, *moniker2, *prefix, *inverse;
IEnumMoniker *enummoniker;
HRESULT hr;
DWORD moniker_type;
@ -2748,6 +2748,45 @@ todo_wine
ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
IMoniker_Release(moniker);
/* CommonPrefixWith() */
hr = CreatePointerMoniker((IUnknown *)&Test_ClassFactory, &moniker);
ok(hr == S_OK, "Failed to create moniker, hr %#x.\n", hr);
hr = CreatePointerMoniker((IUnknown *)&Test_ClassFactory, &moniker2);
ok(hr == S_OK, "Failed to create moniker, hr %#x.\n", hr);
hr = IMoniker_IsEqual(moniker, NULL);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
hr = IMoniker_IsEqual(moniker, moniker2);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMoniker_CommonPrefixWith(moniker, moniker2, NULL);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
hr = IMoniker_CommonPrefixWith(moniker, NULL, &prefix);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
hr = IMoniker_CommonPrefixWith(moniker, moniker2, &prefix);
ok(hr == MK_S_US, "Unexpected hr %#x.\n", hr);
ok(prefix == moniker, "Unexpected pointer.\n");
IMoniker_Release(prefix);
IMoniker_Release(moniker2);
hr = CreatePointerMoniker((IUnknown *)moniker, &moniker2);
ok(hr == S_OK, "Failed to create moniker, hr %#x.\n", hr);
hr = IMoniker_IsEqual(moniker, moniker2);
ok(hr == S_FALSE, "Unexpected hr %#x.\n", hr);
hr = IMoniker_CommonPrefixWith(moniker, moniker2, &prefix);
ok(hr == MK_E_NOPREFIX, "Unexpected hr %#x.\n", hr);
IMoniker_Release(moniker2);
IMoniker_Release(moniker);
}
static void test_bind_context(void)