From 90ede44790d317c123880e0041a0c715a76a099f Mon Sep 17 00:00:00 2001 From: Peter Serwylo Date: Sat, 12 Sep 2015 20:30:07 +1000 Subject: [PATCH] Check for null `netmask` variable to prevent NPE. Not sure if this is the correct course of action to prevent the problem, but it prevents the crash documented in Issue #413. --- F-Droid/src/org/fdroid/fdroid/net/WifiStateChangeService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/F-Droid/src/org/fdroid/fdroid/net/WifiStateChangeService.java b/F-Droid/src/org/fdroid/fdroid/net/WifiStateChangeService.java index c3eedfd0f..860371ec8 100644 --- a/F-Droid/src/org/fdroid/fdroid/net/WifiStateChangeService.java +++ b/F-Droid/src/org/fdroid/fdroid/net/WifiStateChangeService.java @@ -86,7 +86,7 @@ public class WifiStateChangeService extends Service { wifiInfo = wifiManager.getConnectionInfo(); FDroidApp.ipAddressString = formatIpAddress(wifiInfo.getIpAddress()); String netmask = formatIpAddress(wifiManager.getDhcpInfo().netmask); - if (!TextUtils.isEmpty(FDroidApp.ipAddressString)) + if (!TextUtils.isEmpty(FDroidApp.ipAddressString) && netmask != null) FDroidApp.subnetInfo = new SubnetUtils(FDroidApp.ipAddressString, netmask).getInfo(); } else if (wifiState == WifiManager.WIFI_STATE_DISABLED || wifiState == WifiManager.WIFI_STATE_DISABLING) {