From 246b3002a4fc6778e5f739ab9e29115f4e8d4c4b Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Tue, 28 Sep 2021 15:56:31 +0300 Subject: [PATCH] ole32/filemoniker: Fix argument handling in Reduce(). Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/ole32/filemoniker.c | 17 ++++++----------- dlls/ole32/tests/moniker.c | 14 ++++++++++++-- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/dlls/ole32/filemoniker.c b/dlls/ole32/filemoniker.c index f52881108c7..213971ea96b 100644 --- a/dlls/ole32/filemoniker.c +++ b/dlls/ole32/filemoniker.c @@ -608,21 +608,16 @@ FileMonikerImpl_BindToStorage(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLef return E_NOTIMPL; } -/****************************************************************************** - * FileMoniker_Reduce - ******************************************************************************/ -static HRESULT WINAPI -FileMonikerImpl_Reduce(IMoniker* iface, IBindCtx* pbc, DWORD dwReduceHowFar, - IMoniker** ppmkToLeft, IMoniker** ppmkReduced) +static HRESULT WINAPI FileMonikerImpl_Reduce(IMoniker *iface, IBindCtx *pbc, DWORD howfar, + IMoniker **toleft, IMoniker **reduced) { - TRACE("(%p,%p,%d,%p,%p)\n",iface,pbc,dwReduceHowFar,ppmkToLeft,ppmkReduced); + TRACE("%p, %p, %d, %p, %p.\n", iface, pbc, howfar, toleft, reduced); - if (ppmkReduced==NULL) - return E_POINTER; + if (!pbc || !reduced) + return E_INVALIDARG; IMoniker_AddRef(iface); - - *ppmkReduced=iface; + *reduced = iface; return MK_S_REDUCED_TO_SELF; } diff --git a/dlls/ole32/tests/moniker.c b/dlls/ole32/tests/moniker.c index 91382da6a02..2c257dcff50 100644 --- a/dlls/ole32/tests/moniker.c +++ b/dlls/ole32/tests/moniker.c @@ -2098,7 +2098,7 @@ todo_wine static void test_file_moniker(WCHAR* path) { - IMoniker *moniker1 = NULL, *moniker2 = NULL, *inverse, *reduced, *anti; + IMoniker *moniker1 = NULL, *moniker2 = NULL, *m3, *inverse, *reduced, *anti; IEnumMoniker *enummoniker; IBindCtx *bind_ctx; IStream *stream; @@ -2142,9 +2142,19 @@ static void test_file_moniker(WCHAR* path) ok(hr == S_OK, "Failed to create bind context, hr %#x.\n", hr); hr = IMoniker_Reduce(moniker1, NULL, MKRREDUCE_ALL, NULL, &reduced); -todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + hr = IMoniker_Reduce(moniker1, bind_ctx, MKRREDUCE_ALL, NULL, NULL); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + m3 = anti = create_antimoniker(1); + hr = IMoniker_Reduce(moniker1, bind_ctx, MKRREDUCE_ALL, &m3, &reduced); + ok(hr == MK_S_REDUCED_TO_SELF, "Unexpected hr %#x.\n", hr); + ok(reduced == moniker1, "Unexpected moniker.\n"); + ok(m3 == anti, "Unexpected pointer.\n"); + IMoniker_Release(reduced); + IMoniker_Release(anti); + hr = IMoniker_Reduce(moniker1, bind_ctx, MKRREDUCE_ALL, NULL, &reduced); ok(hr == MK_S_REDUCED_TO_SELF, "Unexpected hr %#x.\n", hr); ok(reduced == moniker1, "Unexpected moniker.\n");