Commit 70f35c65 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

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

parent 5a93d972
...@@ -48,9 +48,10 @@ typedef struct PointerMonikerImpl{ ...@@ -48,9 +48,10 @@ typedef struct PointerMonikerImpl{
static inline PointerMonikerImpl *impl_from_IMoniker(IMoniker *iface) 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 static HRESULT WINAPI
PointerMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject) PointerMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject)
{ {
...@@ -58,7 +59,6 @@ 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); TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppvObject);
/* Perform a sanity check on the parameters.*/
if ( (This==0) || (ppvObject==0) ) if ( (This==0) || (ppvObject==0) )
return E_INVALIDARG; return E_INVALIDARG;
...@@ -337,26 +337,20 @@ PointerMonikerImpl_Enum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoni ...@@ -337,26 +337,20 @@ PointerMonikerImpl_Enum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoni
/****************************************************************************** /******************************************************************************
* PointerMoniker_IsEqual * PointerMoniker_IsEqual
******************************************************************************/ ******************************************************************************/
static HRESULT WINAPI static HRESULT WINAPI PointerMonikerImpl_IsEqual(IMoniker *iface, IMoniker *other)
PointerMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker)
{ {
PointerMonikerImpl *This = impl_from_IMoniker(iface); PointerMonikerImpl *moniker = impl_from_IMoniker(iface), *other_moniker;
DWORD mkSys;
TRACE("(%p,%p)\n",iface,pmkOtherMoniker); TRACE("%p, %p.\n", iface, other);
if (pmkOtherMoniker==NULL)
return S_FALSE;
IMoniker_IsSystemMoniker(pmkOtherMoniker,&mkSys); if (!other)
return E_INVALIDARG;
if (mkSys==MKSYS_POINTERMONIKER) other_moniker = unsafe_impl_from_IMoniker(other);
{ if (!other_moniker)
PointerMonikerImpl *pOtherMoniker = impl_from_IMoniker(pmkOtherMoniker);
return This->pObject == pOtherMoniker->pObject ? S_OK : S_FALSE;
}
else
return S_FALSE; return S_FALSE;
return moniker->pObject == other_moniker->pObject ? S_OK : S_FALSE;
} }
/****************************************************************************** /******************************************************************************
...@@ -412,18 +406,20 @@ PointerMonikerImpl_Inverse(IMoniker* iface,IMoniker** ppmk) ...@@ -412,18 +406,20 @@ PointerMonikerImpl_Inverse(IMoniker* iface,IMoniker** ppmk)
/****************************************************************************** /******************************************************************************
* PointerMoniker_CommonPrefixWith * PointerMoniker_CommonPrefixWith
******************************************************************************/ ******************************************************************************/
static HRESULT WINAPI static HRESULT WINAPI PointerMonikerImpl_CommonPrefixWith(IMoniker *iface, IMoniker *other, IMoniker **prefix)
PointerMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther,IMoniker** ppmkPrefix)
{ {
TRACE("(%p, %p)\n", pmkOther, ppmkPrefix); TRACE("%p, %p, %p.\n", iface, other, prefix);
if (!prefix || !other)
return E_INVALIDARG;
*ppmkPrefix = NULL; *prefix = NULL;
if (PointerMonikerImpl_IsEqual(iface, pmkOther)) if (PointerMonikerImpl_IsEqual(iface, other) == S_OK)
{ {
IMoniker_AddRef(iface); IMoniker_AddRef(iface);
*ppmkPrefix=iface; *prefix = iface;
return MK_S_US; return MK_S_US;
} }
...@@ -539,6 +535,13 @@ static const IMonikerVtbl VT_PointerMonikerImpl = ...@@ -539,6 +535,13 @@ static const IMonikerVtbl VT_PointerMonikerImpl =
PointerMonikerImpl_IsSystemMoniker 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) * PointerMoniker_Construct (local function)
*******************************************************************************/ *******************************************************************************/
......
...@@ -2625,7 +2625,7 @@ todo_wine ...@@ -2625,7 +2625,7 @@ todo_wine
static void test_pointer_moniker(void) static void test_pointer_moniker(void)
{ {
IMoniker *moniker, *inverse; IMoniker *moniker, *moniker2, *prefix, *inverse;
IEnumMoniker *enummoniker; IEnumMoniker *enummoniker;
HRESULT hr; HRESULT hr;
DWORD moniker_type; DWORD moniker_type;
...@@ -2748,6 +2748,45 @@ todo_wine ...@@ -2748,6 +2748,45 @@ todo_wine
ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr); ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
IMoniker_Release(moniker); 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) static void test_bind_context(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment