Merge "Ensure connection is non-null" into rvc-dev am: 402bbb4a57

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/11902845

Change-Id: Ia9309066df1666bc0f122af929f2707d0b125ef7
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 3865f29..f011992 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -717,7 +717,7 @@
         for (TouchedMonitor& gestureMonitor : gestureMonitors) {
             sp<Connection> connection =
                     getConnectionLocked(gestureMonitor.monitor.inputChannel->getConnectionToken());
-            if (connection->responsive) {
+            if (connection != nullptr && connection->responsive) {
                 // This monitor could take more input. Drop all events preceding this
                 // event, so that gesture monitor could get a chance to receive the stream
                 ALOGW("Pruning the input queue because %s is unresponsive, but we have a "