NetworkTools: Fix crash when selecting null network items (regression)
@@ -325,20 +325,15 @@ VOID NTAPI NetworkMenuInitializingCallback(
PhInsertEMenuItem(menuInfo->Menu, traceMenu = PhPluginCreateEMenuItem(PluginInstance, 0, NETWORK_ACTION_TRACEROUTE, L"Traceroute", networkItem), 0);
PhInsertEMenuItem(menuInfo->Menu, pingMenu = PhPluginCreateEMenuItem(PluginInstance, 0, NETWORK_ACTION_PING, L"Ping", networkItem), 0);
- if (!networkItem)
+ if (networkItem)
{
- whoisMenu->Flags |= PH_EMENU_DISABLED;
- traceMenu->Flags |= PH_EMENU_DISABLED;
- pingMenu->Flags |= PH_EMENU_DISABLED;
- }
- else if (PhIsNullIpAddress(&networkItem->RemoteEndpoint.Address))
+ if (PhIsNullIpAddress(&networkItem->RemoteEndpoint.Address))
{
whoisMenu->Flags |= PH_EMENU_DISABLED;
traceMenu->Flags |= PH_EMENU_DISABLED;
pingMenu->Flags |= PH_EMENU_DISABLED;
}
-
- if (networkItem->RemoteEndpoint.Address.Type == PH_IPV4_NETWORK_TYPE)
+ else if (networkItem->RemoteEndpoint.Address.Type == PH_IPV4_NETWORK_TYPE)
{
if (IN4_IS_ADDR_LOOPBACK(&networkItem->RemoteEndpoint.Address.InAddr))
{
@@ -357,6 +352,13 @@ VOID NTAPI NetworkMenuInitializingCallback(
}
}
}
+ else
+ {
+ whoisMenu->Flags |= PH_EMENU_DISABLED;
+ traceMenu->Flags |= PH_EMENU_DISABLED;
+ pingMenu->Flags |= PH_EMENU_DISABLED;
+ }
+}
LONG NTAPI NetworkServiceSortFunction(
_In_ PVOID Node1,
