File tree 1 file changed +13
-2
lines changed
1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,12 @@ class __declspec(uuid("8F491918-259F-451A-950F-8C3EBF4864AF")) ImageResizerConte
79
79
80
80
IFACEMETHODIMP GetState (_In_opt_ IShellItemArray* selection, _In_ BOOL okToBeSlow, _Out_ EXPCMDSTATE* cmdState)
81
81
{
82
+ if (nullptr == selection) {
83
+ // We've observed that it's possible that a null gets passed instead of an empty array. Just don't show the context menu in this case.
84
+ *cmdState = ECS_HIDDEN;
85
+ return S_OK;
86
+ }
87
+
82
88
if (!CSettingsInstance ().GetEnabled ())
83
89
{
84
90
*cmdState = ECS_HIDDEN;
@@ -90,9 +96,14 @@ class __declspec(uuid("8F491918-259F-451A-950F-8C3EBF4864AF")) ImageResizerConte
90
96
#pragma warning(suppress : 26812)
91
97
PERCEIVED type;
92
98
PERCEIVEDFLAG flag;
93
- IShellItem* shellItem;
99
+ IShellItem* shellItem= nullptr ;
94
100
// Check extension of first item in the list (the item which is right-clicked on)
95
- selection->GetItemAt (0 , &shellItem);
101
+ HRESULT getItemResult = selection->GetItemAt (0 , &shellItem);
102
+ if (S_OK != getItemResult || nullptr == shellItem) {
103
+ // Some safeguards to avoid runtime errors.
104
+ *cmdState = ECS_HIDDEN;
105
+ return S_OK;
106
+ }
96
107
LPTSTR pszPath;
97
108
// Retrieves the entire file system path of the file from its shell item
98
109
shellItem->GetDisplayName (SIGDN_FILESYSPATH, &pszPath);
You can’t perform that action at this time.
0 commit comments