[SHELL32] Handle BYREF variants in CFolderItems::Item.
authorThomas Faber <thomas.faber@reactos.org>
Sun, 8 Sep 2019 09:10:29 +0000 (11:10 +0200)
committerThomas Faber <thomas.faber@reactos.org>
Sun, 22 Sep 2019 09:41:57 +0000 (11:41 +0200)
Fixes crash in shell32_winetest:shelldispatch.

See also:
https://source.winehq.org/git/wine.git/commitdiff/6634b31520d56efb7f9b815132d5f7b29d6e43dd

dll/win32/shell32/CFolderItems.cpp

index 9d2e270..5952120 100644 (file)
@@ -247,11 +247,18 @@ HRESULT STDMETHODCALLTYPE CFolderItems::get_Parent(IDispatch **ppid)
     return E_NOTIMPL;
 }
 
-HRESULT STDMETHODCALLTYPE CFolderItems::Item(VARIANT index, FolderItem **ppid)
+HRESULT STDMETHODCALLTYPE CFolderItems::Item(VARIANT var, FolderItem **ppid)
 {
+    CComVariant index;
+    HRESULT hr;
+
     if (!m_EnumIDList)
         return E_FAIL;
 
+    hr = VariantCopyInd(&index, &var);
+    if (FAILED(hr))
+        return hr;
+
     if (V_VT(&index) == VT_I2)
         VariantChangeType(&index, &index, 0, VT_I4);
 
@@ -259,7 +266,7 @@ HRESULT STDMETHODCALLTYPE CFolderItems::Item(VARIANT index, FolderItem **ppid)
     {
         ULONG count = V_UI4(&index);
 
-        HRESULT hr = m_EnumIDList->Reset();
+        hr = m_EnumIDList->Reset();
         if (FAILED_UNEXPECTEDLY(hr))
             return hr;
 
@@ -282,7 +289,7 @@ HRESULT STDMETHODCALLTYPE CFolderItems::Item(VARIANT index, FolderItem **ppid)
         if (!V_BSTR(&index))
             return S_FALSE;
 
-        HRESULT hr = m_Folder->ParseName(V_BSTR(&index), ppid);
+        hr = m_Folder->ParseName(V_BSTR(&index), ppid);
         if (FAILED_UNEXPECTEDLY(hr))
             return hr;
         return hr;