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

Commit 8906d1d9 authored by Pirama Arumuga Nainar's avatar Pirama Arumuga Nainar Committed by Gerrit Code Review
Browse files

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

parents 412d19a0 ee2f164e
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -8132,6 +8132,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) {
@@ -8179,6 +8190,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();
}
/**