From 31e19f34f56a01a7b4133cd1dccf13b18b469ac7 Mon Sep 17 00:00:00 2001 From: Lorenzo Colitti Date: Tue, 11 Aug 2015 15:42:59 +0900 Subject: [PATCH] Don't attempt to stop the receive thread if we never started it. If socket initialization fails, DhcpState#exit will call mReceiveThread#stop and crash the system with an NPE. Make sure we don't do that if mReceiveThread is null, and properly null it out when exiting. Bug: 23088314 Change-Id: I4378d8280f9d8588f5eaa8bd7ade61beab1c3ce2 --- services/net/java/android/net/dhcp/DhcpClient.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/net/java/android/net/dhcp/DhcpClient.java b/services/net/java/android/net/dhcp/DhcpClient.java index 2d40291176771..9ee9cf4fbcc62 100644 --- a/services/net/java/android/net/dhcp/DhcpClient.java +++ b/services/net/java/android/net/dhcp/DhcpClient.java @@ -603,7 +603,10 @@ public class DhcpClient extends BaseDhcpStateMachine { @Override public void exit() { cancelOneshotTimeout(); - mReceiveThread.halt(); // Also closes sockets. + if (mReceiveThread != null) { + mReceiveThread.halt(); // Also closes sockets. + mReceiveThread = null; + } clearDhcpState(); }