[SHELL32] Fix some NULL-pointers validation.

- In the exported SHCreateDefaultContextMenu() and
  IDataObject_Constructor() functions (called amongst others by
  the exported CIDLData_CreateFromIDArray() function).

- In the exported SHCreateShellFolderView() function.

- In CDefView::GetItemObject(), where data was written to *ppvOut before
  ppvOut was being checked for NULL.
This commit is contained in:
Hermès Bélusca-Maïto 2019-06-08 19:43:02 +02:00
parent 47d76db311
commit ae2a85d003
No known key found for this signature in database
GPG Key ID: 3B2539C65E7B93D0
3 changed files with 14 additions and 6 deletions

View File

@ -2419,6 +2419,9 @@ HRESULT WINAPI CDefView::GetItemObject(UINT uItem, REFIID riid, LPVOID *ppvOut)
TRACE("(%p)->(uItem=0x%08x,\n\tIID=%s, ppv=%p)\n", this, uItem, debugstr_guid(&riid), ppvOut);
if (!ppvOut)
return E_INVALIDARG;
*ppvOut = NULL;
switch (uItem)
@ -2426,9 +2429,6 @@ HRESULT WINAPI CDefView::GetItemObject(UINT uItem, REFIID riid, LPVOID *ppvOut)
case SVGIO_BACKGROUND:
if (IsEqualIID(riid, IID_IContextMenu))
{
if (!ppvOut)
hr = E_OUTOFMEMORY;
hr = CDefViewBckgrndMenu_CreateInstance(m_pSF2Parent, riid, ppvOut);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
@ -3449,13 +3449,14 @@ HRESULT WINAPI SHCreateShellFolderView(const SFV_CREATE *pcsfv,
CComPtr<IShellView> psv;
HRESULT hRes;
*ppsv = NULL;
if (!pcsfv || pcsfv->cbSize != sizeof(*pcsfv))
if (!ppsv || !pcsfv || pcsfv->cbSize != sizeof(*pcsfv))
return E_INVALIDARG;
TRACE("sf=%p outer=%p callback=%p\n",
pcsfv->pshf, pcsfv->psvOuter, pcsfv->psfvcb);
*ppsv = NULL;
hRes = CDefView_CreateInstance(pcsfv->pshf, IID_PPV_ARG(IShellView, &psv));
if (FAILED(hRes))
return hRes;

View File

@ -1472,7 +1472,12 @@ HRESULT
WINAPI
SHCreateDefaultContextMenu(const DEFCONTEXTMENU *pdcm, REFIID riid, void **ppv)
{
HRESULT hr = CDefaultContextMenu_CreateInstance(pdcm, NULL, riid, ppv);
HRESULT hr;
if (!ppv)
return E_INVALIDARG;
hr = CDefaultContextMenu_CreateInstance(pdcm, NULL, riid, ppv);
if (FAILED_UNEXPECTEDLY(hr))
return hr;

View File

@ -410,6 +410,8 @@ HRESULT WINAPI CIDLDataObj::EndOperation(HRESULT hResult, IBindCtx *pbcReserved,
*/
HRESULT IDataObject_Constructor(HWND hwndOwner, PCIDLIST_ABSOLUTE pMyPidl, PCUIDLIST_RELATIVE_ARRAY apidl, UINT cidl, IDataObject **dataObject)
{
if (!dataObject)
return E_INVALIDARG;
return ShellObjectCreatorInit<CIDLDataObj>(hwndOwner, pMyPidl, apidl, cidl, IID_PPV_ARG(IDataObject, dataObject));
}