https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0d077c3068639576858164b837c8aafc59caf936

commit 0d077c3068639576858164b837c8aafc59caf936
Author:     Ioannis Adamopoulos <[email protected]>
AuthorDate: Mon Apr 20 17:35:34 2020 +0300
Commit:     Ioannis Adamopoulos <[email protected]>
CommitDate: Mon Apr 20 17:37:03 2020 +0300

    [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.
---
 dll/win32/shell32/folders/CDesktopFolder.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/dll/win32/shell32/folders/CDesktopFolder.cpp 
b/dll/win32/shell32/folders/CDesktopFolder.cpp
index f2d6c32e09c..9c79cecbb1f 100644
--- a/dll/win32/shell32/folders/CDesktopFolder.cpp
+++ b/dll/win32/shell32/folders/CDesktopFolder.cpp
@@ -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;

Reply via email to