shell32: Don't crash on NULL cmdgroup in DefView OleCommandTarget.

This commit is contained in:
David Hedberg 2010-11-08 00:06:14 +01:00 committed by Alexandre Julliard
parent 208aeedcda
commit 18d31c2799
2 changed files with 47 additions and 1 deletions

View File

@ -2258,7 +2258,7 @@ static HRESULT WINAPI ISVOleCmdTarget_QueryStatus(
This, debugstr_guid(pguidCmdGroup), cCmds, prgCmds, pCmdText);
if (!prgCmds)
return E_POINTER;
return E_INVALIDARG;
for (i = 0; i < cCmds; i++)
{
FIXME("\tprgCmds[%d].cmdID = %d\n", i, prgCmds[i].cmdID);
@ -2285,6 +2285,8 @@ static HRESULT WINAPI ISVOleCmdTarget_Exec(
FIXME("(%p)->(\n\tTarget GUID:%s Command:0x%08x Opt:0x%08x %p %p)\n",
This, debugstr_guid(pguidCmdGroup), nCmdID, nCmdexecopt, pvaIn, pvaOut);
if (!pguidCmdGroup)
return OLECMDERR_E_UNKNOWNGROUP;
if (IsEqualIID(pguidCmdGroup, &CGID_Explorer) &&
(nCmdID == 0x29) &&
(nCmdexecopt == 4) && pvaOut)

View File

@ -1100,6 +1100,49 @@ static void test_GetSetCurrentViewMode(void)
IShellFolder_Release(desktop);
}
static void test_IOleCommandTarget(void)
{
IShellFolder *psf_desktop;
IShellView *psv;
IOleCommandTarget *poct;
HRESULT hr;
hr = SHGetDesktopFolder(&psf_desktop);
ok(hr == S_OK, "got (0x%08x)\n", hr);
hr = IShellFolder_CreateViewObject(psf_desktop, NULL, &IID_IShellView, (void**)&psv);
ok(hr == S_OK, "got (0x%08x)\n", hr);
if(SUCCEEDED(hr))
{
hr = IShellView_QueryInterface(psv, &IID_IOleCommandTarget, (void**)&poct);
ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* Win95/NT4 */, "Got 0x%08x\n", hr);
if(SUCCEEDED(hr))
{
OLECMD oc;
hr = IOleCommandTarget_QueryStatus(poct, NULL, 0, NULL, NULL);
ok(hr == E_INVALIDARG, "Got 0x%08x\n", hr);
oc.cmdID = 1;
hr = IOleCommandTarget_QueryStatus(poct, NULL, 0, &oc, NULL);
ok(hr == OLECMDERR_E_UNKNOWNGROUP, "Got 0x%08x\n", hr);
oc.cmdID = 1;
hr = IOleCommandTarget_QueryStatus(poct, NULL, 1, &oc, NULL);
ok(hr == OLECMDERR_E_UNKNOWNGROUP, "Got 0x%08x\n", hr);
hr = IOleCommandTarget_Exec(poct, NULL, 0, 0, NULL, NULL);
ok(hr == OLECMDERR_E_UNKNOWNGROUP, "Got 0x%08x\n", hr);
IOleCommandTarget_Release(poct);
}
IShellView_Release(psv);
}
IShellFolder_Release(psf_desktop);
}
START_TEST(shlview)
{
OleInitialize(NULL);
@ -1112,6 +1155,7 @@ START_TEST(shlview)
test_IShellFolderView();
test_IOleWindow();
test_GetSetCurrentViewMode();
test_IOleCommandTarget();
OleUninitialize();
}