mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
[ImageResizer]Fix call to AssocGetPerceivedType (#23267)
This commit is contained in:
@@ -106,8 +106,20 @@ public:
|
||||
}
|
||||
LPTSTR pszPath;
|
||||
// Retrieves the entire file system path of the file from its shell item
|
||||
shellItem->GetDisplayName(SIGDN_FILESYSPATH, &pszPath);
|
||||
HRESULT getDisplayResult = shellItem->GetDisplayName(SIGDN_FILESYSPATH, &pszPath);
|
||||
if (S_OK != getDisplayResult || nullptr == pszPath)
|
||||
{
|
||||
// Avoid crashes in the following code.
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
LPTSTR pszExt = PathFindExtension(pszPath);
|
||||
if (nullptr == pszExt)
|
||||
{
|
||||
CoTaskMemFree(pszPath);
|
||||
// Avoid crashes in the following code.
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
// TODO: Instead, detect whether there's a WIC codec installed that can handle this file
|
||||
AssocGetPerceivedType(pszExt, &type, &flag, NULL);
|
||||
|
||||
@@ -82,7 +82,19 @@ HRESULT CContextMenuHandler::QueryContextMenu(_In_ HMENU hmenu, UINT indexMenu,
|
||||
PERCEIVED type;
|
||||
PERCEIVEDFLAG flag;
|
||||
LPTSTR pszPath = i.CurrentItem();
|
||||
if (nullptr == pszPath)
|
||||
{
|
||||
// Avoid crashes in the following code.
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
LPTSTR pszExt = PathFindExtension(pszPath);
|
||||
if (nullptr == pszExt)
|
||||
{
|
||||
free(pszPath);
|
||||
// Avoid crashes in the following code.
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
// TODO: Instead, detect whether there's a WIC codec installed that can handle this file
|
||||
AssocGetPerceivedType(pszExt, &type, &flag, NULL);
|
||||
@@ -378,8 +390,20 @@ HRESULT __stdcall CContextMenuHandler::GetState(IShellItemArray* psiItemArray, B
|
||||
psiItemArray->GetItemAt(0, &shellItem);
|
||||
LPTSTR pszPath;
|
||||
// Retrieves the entire file system path of the file from its shell item
|
||||
shellItem->GetDisplayName(SIGDN_FILESYSPATH, &pszPath);
|
||||
HRESULT getDisplayResult = shellItem->GetDisplayName(SIGDN_FILESYSPATH, &pszPath);
|
||||
if (S_OK != getDisplayResult || nullptr == pszPath)
|
||||
{
|
||||
// Avoid crashes in the following code.
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
LPTSTR pszExt = PathFindExtension(pszPath);
|
||||
if (nullptr == pszExt)
|
||||
{
|
||||
CoTaskMemFree(pszPath);
|
||||
// Avoid crashes in the following code.
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
// TODO: Instead, detect whether there's a WIC codec installed that can handle this file
|
||||
AssocGetPerceivedType(pszExt, &type, &flag, NULL);
|
||||
|
||||
Reference in New Issue
Block a user