From dff1c98d8203a082395e4123b15c7d5805959e85 Mon Sep 17 00:00:00 2001 From: dpastor Date: Thu, 30 Nov 2023 09:18:09 +0100 Subject: [PATCH] ANDROID-13965 Prevent implementation from crashing in case ACTION_POINTER_UP with an invalid pointer is received (#14) --- .../nestedscrollwebview/NestedScrollWebView.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nestedscrollwebview/src/main/java/com/telefonica/nestedscrollwebview/NestedScrollWebView.java b/nestedscrollwebview/src/main/java/com/telefonica/nestedscrollwebview/NestedScrollWebView.java index ba8874e..f2467a3 100644 --- a/nestedscrollwebview/src/main/java/com/telefonica/nestedscrollwebview/NestedScrollWebView.java +++ b/nestedscrollwebview/src/main/java/com/telefonica/nestedscrollwebview/NestedScrollWebView.java @@ -365,6 +365,13 @@ public void onNestedTouchEvent(@NonNull MotionEvent ev) { } case MotionEvent.ACTION_POINTER_UP: onSecondaryPointerUp(ev); + /* Code not present on NestedScrollView code. + Prevent crash on last motion update due an invalid pointerId. */ + if (ev.findPointerIndex(mActivePointerId) == -1) { + Log.e(TAG, "Invalid pointerId=" + mActivePointerId + " in onTouchEvent for ACTION_POINTER_UP"); + break; + } + /* End of code not present on NestedScrollView code. */ mLastMotionY = (int) ev.getY(ev.findPointerIndex(mActivePointerId)); break; }