Skip to content

Commit

Permalink
[ImageResizer]Check for files in HDropIterator before processing (#20985
Browse files Browse the repository at this point in the history
)
  • Loading branch information
stefansjfw committed Oct 3, 2022
1 parent 5e955f0 commit 6d531a9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/common/utils/HDropIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class HDropIterator
HDropIterator(IDataObject* pDataObject)
{
_current = 0;
_listCount = 0;

FORMATETC formatetc = {
CF_HDROP,
Expand All @@ -16,14 +17,22 @@ class HDropIterator
TYMED_HGLOBAL
};

pDataObject->GetData(&formatetc, &m_medium);

_listCount = DragQueryFile((HDROP)m_medium.hGlobal, 0xFFFFFFFF, NULL, 0);
if (SUCCEEDED(pDataObject->GetData(&formatetc, &m_medium)))
{
_listCount = DragQueryFile((HDROP)m_medium.hGlobal, 0xFFFFFFFF, NULL, 0);
}
else
{
m_medium = {};
}
}

~HDropIterator()
{
ReleaseStgMedium(&m_medium);
if (m_medium.tymed)
{
ReleaseStgMedium(&m_medium);
}
}

void First()
Expand Down
5 changes: 5 additions & 0 deletions src/modules/imageresizer/dll/ContextMenuHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ HRESULT CContextMenuHandler::QueryContextMenu(_In_ HMENU hmenu, UINT indexMenu,
// NB: We just check the first item. We could iterate through more if the first one doesn't meet the criteria
HDropIterator i(m_pdtobj);
i.First();
if (i.IsDone())
{
return S_OK;
}

// Suppressing C26812 warning as the issue is in the shtypes.h library
#pragma warning(suppress : 26812)
PERCEIVED type;
Expand Down

0 comments on commit 6d531a9

Please sign in to comment.