https://git.reactos.org/?p=reactos.git;a=commitdiff;h=faae7e57902dba58da03b4158025761a71eef3f3
commit faae7e57902dba58da03b4158025761a71eef3f3 Author: Thomas Faber <thomas.fa...@reactos.org> AuthorDate: Sun Sep 8 11:10:29 2019 +0200 Commit: Thomas Faber <thomas.fa...@reactos.org> CommitDate: Sun Sep 22 11:41:57 2019 +0200 [SHELL32] Handle BYREF variants in CFolderItems::Item. Fixes crash in shell32_winetest:shelldispatch. See also: https://source.winehq.org/git/wine.git/commitdiff/6634b31520d56efb7f9b815132d5f7b29d6e43dd --- dll/win32/shell32/CFolderItems.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/dll/win32/shell32/CFolderItems.cpp b/dll/win32/shell32/CFolderItems.cpp index 9d2e27090bb..5952120c80f 100644 --- a/dll/win32/shell32/CFolderItems.cpp +++ b/dll/win32/shell32/CFolderItems.cpp @@ -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;