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

Skip to content
Commit ccf45996 authored by Arpit Singh's avatar Arpit Singh
Browse files

Refactor native MotionEvent_obtain to avoid possible memory leak

android_view_MotionEvent_setNativePtr doesn't check if the supplied java
MotionEvent already holds a native pointer before overwriting it. This
can potentially cause native MotionEvent object to be leaked.

Currently this is only used in android_view_MotionEvent_obtainFromNative
without checking for existing native pointer in corresponding java
object. This can potantially leak native heap in
android.view.MotionPredictor if the obtained java MotionEvent was
recycled and holding a native MotionEvent object.

In this CL we change it to first check for existing native object and
copy the data instead avoiding allocating new native MotionEvent. This
will also allow us to safely use it in MotionEvent_obtainAsCopy method.

Test: atest MotionEventTest
Bug: 328562482
Bug: 324375527
Change-Id: Iff6b4211ea23a940dcfe3acddd4464ccdc0799d1
parent 773f9511
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment