Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ff4a159e authored by Pirama Arumuga Nainar's avatar Pirama Arumuga Nainar Committed by Automerger Merge Worker
Browse files

Merge "inputflinger_tests: Fix asan error about new-delete type mismatch" into...

Merge "inputflinger_tests: Fix asan error about new-delete type mismatch" into main am: 8906d1d9 am: 04023f3e

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



Change-Id: I5671eb4828504abfebc5cc21beaa09751b6efcf9
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 4961d9bc 04023f3e
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -8101,6 +8101,17 @@ TEST_F(InputDispatcherTest, VerifyInputEvent_KeyEvent) {
    ASSERT_EQ(keyArgs.scanCode, verifiedKey.scanCode);
    ASSERT_EQ(keyArgs.metaState, verifiedKey.metaState);
    ASSERT_EQ(0, verifiedKey.repeatCount);
    // InputEvent and subclasses don't have a virtual destructor and only
    // InputEvent's destructor gets called when `verified` goes out of scope,
    // even if `verifyInputEvent` returns an object of a subclass.  To fix this,
    // we should either consider using std::variant in some way, or introduce an
    // intermediate POD data structure that we will put the data into just prior
    // to signing.  Adding virtual functions to these classes is undesirable as
    // the bytes in these objects are getting signed.  As a temporary fix, cast
    // the pointer to the correct class (which is statically known) before
    // destruction.
    delete (VerifiedKeyEvent*)verified.release();
}
TEST_F(InputDispatcherTest, VerifyInputEvent_MotionEvent) {
@@ -8148,6 +8159,10 @@ TEST_F(InputDispatcherTest, VerifyInputEvent_MotionEvent) {
    EXPECT_EQ(motionArgs.downTime, verifiedMotion.downTimeNanos);
    EXPECT_EQ(motionArgs.metaState, verifiedMotion.metaState);
    EXPECT_EQ(motionArgs.buttonState, verifiedMotion.buttonState);
    // Cast to the correct type before destruction.  See explanation at the end
    // of the VerifyInputEvent_KeyEvent test.
    delete (VerifiedMotionEvent*)verified.release();
}
/**