Fix use after free in InputClassifier
Do not send address of a variable outside of the scope of the variable.
Test: presubmit
Bug: 124232816
Change-Id: I18b4e27ef333f3a8354bdeba89ea2a912106cdaa
diff --git a/services/inputflinger/InputClassifier.cpp b/services/inputflinger/InputClassifier.cpp
index 09a004c..3905ed0 100644
--- a/services/inputflinger/InputClassifier.cpp
+++ b/services/inputflinger/InputClassifier.cpp
@@ -705,13 +705,12 @@
}
void InputClassifier::notifyMotion(const NotifyMotionArgs* args) {
+ NotifyMotionArgs copyArgs = NotifyMotionArgs(*args);
if (mMotionClassifier && isTouchEvent(*args)) {
// We only cover touch events, for now.
- NotifyMotionArgs newArgs = NotifyMotionArgs(*args);
- newArgs.classification = mMotionClassifier->classify(newArgs);
- args = &newArgs;
+ copyArgs.classification = mMotionClassifier->classify(copyArgs);
}
- mListener->notifyMotion(args);
+ mListener->notifyMotion(©Args);
}
void InputClassifier::notifySwitch(const NotifySwitchArgs* args) {