Skip to content

Commit 21326d8

Browse files
cwhuangandroid-x86
authored andcommitted
Avoid system_server crashing due to mac address is null
It's possible that the mac address is null (getMacAddress() of WifiNative.java). In this case system_server will crash like: E AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: WifiWatchdogStateMachine E AndroidRuntime: java.lang.NullPointerException E AndroidRuntime: at android.net.arp.ArpPeer.<init>(ArpPeer.java:57) E AndroidRuntime: at android.net.wifi.WifiWatchdogStateMachine.doArpTest(WifiWatchdogStateMachine.java:866) Check the mac address before parsing to avoid crashing. Change-Id: I5d4205c04d479a3a2837172c6382816ea4bf74d6
1 parent b0b4a70 commit 21326d8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

core/java/android/net/arp/ArpPeer.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,11 @@ public ArpPeer(String interfaceName, InetAddress myAddr, String mac,
5353
mInterfaceName = interfaceName;
5454
mMyAddr = myAddr;
5555

56-
for (int i = 0; i < MAC_ADDR_LENGTH; i++) {
57-
mMyMac[i] = (byte) Integer.parseInt(mac.substring(
58-
i*3, (i*3) + 2), 16);
56+
if (mac != null) {
57+
for (int i = 0; i < MAC_ADDR_LENGTH; i++) {
58+
mMyMac[i] = (byte) Integer.parseInt(mac.substring(
59+
i*3, (i*3) + 2), 16);
60+
}
5961
}
6062

6163
if (myAddr instanceof Inet6Address || peer instanceof Inet6Address) {

0 commit comments

Comments
 (0)