From 40ad4706434b40fa466b23c6e9f03f6dcc32c0c4 Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Thu, 16 Sep 2010 11:02:16 -0700 Subject: [PATCH] Fix NPE when handling certain kinds of ANRs. Change-Id: Iccef1852e52c84f6f49d30c491431460a10b33d3 --- libs/ui/InputDispatcher.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libs/ui/InputDispatcher.cpp b/libs/ui/InputDispatcher.cpp index 3b3c48317..dea7936f1 100644 --- a/libs/ui/InputDispatcher.cpp +++ b/libs/ui/InputDispatcher.cpp @@ -777,10 +777,12 @@ void InputDispatcher::resumeAfterTargetsNotReadyTimeoutLocked(nsecs_t newTimeout mInputTargetWaitTimeoutExpired = true; // Input state will not be realistic. Mark it out of sync. - ssize_t connectionIndex = getConnectionIndexLocked(inputChannel); - if (connectionIndex >= 0) { - sp connection = mConnectionsByReceiveFd.valueAt(connectionIndex); - connection->inputState.setOutOfSync(); + if (inputChannel.get()) { + ssize_t connectionIndex = getConnectionIndexLocked(inputChannel); + if (connectionIndex >= 0) { + sp connection = mConnectionsByReceiveFd.valueAt(connectionIndex); + connection->inputState.setOutOfSync(); + } } } }