From b119e2921888ac24a8615f9883bac45c2950c2a5 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Wed, 6 Jan 2021 00:32:28 +0100 Subject: [PATCH] NetworkActivity: Fix an exceedingly unlikely crash. If you're *extremely* unlucky, the scheduled check might run *right* after a wakeup, before the network interface is up. So, you have a previously stored packet count, but the new one is nil. Boom. --- frontend/ui/network/networklistener.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/ui/network/networklistener.lua b/frontend/ui/network/networklistener.lua index a491e5cd8..9e54d61f0 100644 --- a/frontend/ui/network/networklistener.lua +++ b/frontend/ui/network/networklistener.lua @@ -139,7 +139,7 @@ function NetworkListener:_scheduleActivityCheck() local keep_checking = true local tx_packets = NetworkListener:_getTxPackets() - if self._last_tx_packets then + if self._last_tx_packets and tx_packets then -- Compute noise threshold based on the current delay local delay = self._activity_check_delay or default_network_timeout_seconds local noise_threshold = delay / default_network_timeout_seconds * network_activity_noise_margin