[SHELL32] CDesktopFolder::GetUIObjectOf: fix crash when requested to create a IID_IContextMenu for 0 items.

* Tests show that we should return a valid object even in this case.
This commit is contained in:
Ioannis Adamopoulos 2020-04-20 17:35:34 +03:00
parent d2b91deb33
commit 0d077c3068

View file

@ -608,7 +608,7 @@ HRESULT WINAPI CDesktopFolder::GetUIObjectOf(
if (IsEqualIID (riid, IID_IContextMenu))
{
if (_ILIsSpecialFolder(apidl[0]))
if (cidl > 0 && _ILIsSpecialFolder(apidl[0]))
{
hr = m_regFolder->GetUIObjectOf(hwndOwner, cidl, apidl, riid, prgfInOut, &pObj);
}
@ -619,7 +619,10 @@ HRESULT WINAPI CDesktopFolder::GetUIObjectOf(
/* Otherwise operations like that involve items from both user and shared desktop will not work */
HKEY hKeys[16];
UINT cKeys = 0;
AddFSClassKeysToArray(apidl[0], hKeys, &cKeys);
if (cidl > 0)
{
AddFSClassKeysToArray(apidl[0], hKeys, &cKeys);
}
DEFCONTEXTMENU dcm;
dcm.hwnd = hwndOwner;