Skip to content

Commit

Permalink
Merge pull request #213 from Automattic/issue/212-fix-invalid-pointer…
Browse files Browse the repository at this point in the history
…-index-crash

add a check before attempting to use an invalid pointer index
  • Loading branch information
mzorz authored Nov 27, 2019
2 parents 7c5a523 + 8e01aa3 commit 35e597c
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ class RotationGestureDetector {
MotionEvent.ACTION_DOWN -> ptrID1 = event.getPointerId(event.actionIndex)
MotionEvent.ACTION_POINTER_DOWN -> {
ptrID2 = event.getPointerId(event.actionIndex)
sX = event.getX(event.findPointerIndex(ptrID1))
sY = event.getY(event.findPointerIndex(ptrID1))
fX = event.getX(event.findPointerIndex(ptrID2))
fY = event.getY(event.findPointerIndex(ptrID2))
if (ptrID1 != INVALID_POINTER_ID && ptrID2 != INVALID_POINTER_ID) {
sX = event.getX(event.findPointerIndex(ptrID1))
sY = event.getY(event.findPointerIndex(ptrID1))
fX = event.getX(event.findPointerIndex(ptrID2))
fY = event.getY(event.findPointerIndex(ptrID2))

val pvx = fX - sX
val pvy = fY - sY
val pvx = fX - sX
val pvy = fY - sY

prevSpanVector.set(pvx, pvy)
prevSpanVector.set(pvx, pvy)
}
}
MotionEvent.ACTION_MOVE -> if (ptrID1 != INVALID_POINTER_ID && ptrID2 != INVALID_POINTER_ID) {
val nfX: Float
Expand Down

0 comments on commit 35e597c

Please sign in to comment.