Skip to content

Commit ffbd83c

Browse files
committed
input: don't log the whole MotionEvent in index checks
We've had a crash report where this causes infinite recursion, probably through the following call sequence: operator<<(std::ostream&, const MotionEvent&) → MotionEvent::get(X|Y) → MotionEvent::getAxisValue → MotionEvent::getHistoricalAxisValue → MotionEvent::getHistoricalRawPointerCoords → operator<<(std::ostream&, const MotionEvent&) It's unclear how the MotionEvent gets corrupted such that getHistoricalRawPointerCoords is called with invalid indexes, but the simple fix is to only log a useful subset of the whole event in these checks. Bug: 379368465 Test: m checkinput Flag: EXEMPT bug fix Change-Id: I0822f88fc7da6ba08ba6dbbab71ca5aaf78fc35d
1 parent 6e56673 commit ffbd83c

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

libs/input/Input.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -705,15 +705,17 @@ float MotionEvent::getAxisValue(int32_t axis, size_t pointerIndex) const {
705705
const PointerCoords* MotionEvent::getHistoricalRawPointerCoords(
706706
size_t pointerIndex, size_t historicalIndex) const {
707707
if (CC_UNLIKELY(pointerIndex < 0 || pointerIndex >= getPointerCount())) {
708-
LOG(FATAL) << __func__ << ": Invalid pointer index " << pointerIndex << " for " << *this;
708+
LOG(FATAL) << __func__ << ": Invalid pointer index " << pointerIndex
709+
<< "; should be between >0 and ≤" << getPointerCount();
709710
}
710711
if (CC_UNLIKELY(historicalIndex < 0 || historicalIndex > getHistorySize())) {
711-
LOG(FATAL) << __func__ << ": Invalid historical index " << historicalIndex << " for "
712-
<< *this;
712+
LOG(FATAL) << __func__ << ": Invalid historical index " << historicalIndex
713+
<< "; should be >0 and ≤" << getHistorySize();
713714
}
714715
const size_t position = historicalIndex * getPointerCount() + pointerIndex;
715716
if (CC_UNLIKELY(position < 0 || position >= mSamplePointerCoords.size())) {
716-
LOG(FATAL) << __func__ << ": Invalid array index " << position << " for " << *this;
717+
LOG(FATAL) << __func__ << ": Invalid array index " << position << "; should be >0 and ≤"
718+
<< mSamplePointerCoords.size();
717719
}
718720
return &mSamplePointerCoords[position];
719721
}

0 commit comments

Comments
 (0)