[ImageResizer]Check for files in HDropIterator before processing (#20985)

This commit is contained in:
Stefan Markovic
2022-10-03 12:13:48 +02:00
committed by GitHub
parent 5e955f034e
commit 6d531a9a6b
2 changed files with 18 additions and 4 deletions

View File

@@ -7,6 +7,7 @@ public:
HDropIterator(IDataObject* pDataObject) HDropIterator(IDataObject* pDataObject)
{ {
_current = 0; _current = 0;
_listCount = 0;
FORMATETC formatetc = { FORMATETC formatetc = {
CF_HDROP, CF_HDROP,
@@ -16,14 +17,22 @@ public:
TYMED_HGLOBAL TYMED_HGLOBAL
}; };
pDataObject->GetData(&formatetc, &m_medium); if (SUCCEEDED(pDataObject->GetData(&formatetc, &m_medium)))
{
_listCount = DragQueryFile((HDROP)m_medium.hGlobal, 0xFFFFFFFF, NULL, 0); _listCount = DragQueryFile((HDROP)m_medium.hGlobal, 0xFFFFFFFF, NULL, 0);
}
else
{
m_medium = {};
}
} }
~HDropIterator() ~HDropIterator()
{ {
ReleaseStgMedium(&m_medium); if (m_medium.tymed)
{
ReleaseStgMedium(&m_medium);
}
} }
void First() void First()

View File

@@ -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 // 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); HDropIterator i(m_pdtobj);
i.First(); i.First();
if (i.IsDone())
{
return S_OK;
}
// Suppressing C26812 warning as the issue is in the shtypes.h library // Suppressing C26812 warning as the issue is in the shtypes.h library
#pragma warning(suppress : 26812) #pragma warning(suppress : 26812)
PERCEIVED type; PERCEIVED type;