+1
−1
Loading
Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more
* Fix memory leak happen in below two cases Case 1 1. Reactable1 register 2. Reactable2 register 3. Reactable2 unregister during the callback event of Reactable2 4. Reactable1 unregister In step 3, reactable_removed_ will set to true due to unregister while reactable->is_executing_ is true, it makes sure we delete Reactable2 after the callback is executed. But it will cause Reactable1 to not be deleted in step 4. To avoid this, we can reset reactable_removed_ to false after Reactable deleted. Case 2 1. Reactable1 register 2. Reactable2 register 3. Reactable2 unregister during the callback event of Reactable2 4. Reactable1 unregister from different thread during step 3 processing In step 3, although we reset reactable_removed_ to false after Reactable2 deleted immediately for case 1, if other thread unregister Reactable1 before Reactable2 deleted, Reactable1 will fail to be deleted. To avoid thie, we add a local variable to check if the Reacable is executing. If not, deleted the Reactable directly. * Add unittest for these two cases * Fix memory leak in reactor_unittest * Turn on cfi and address flag Test: sudo ./bluetooth_test_gd Change-Id: I0a0ca79b439fd3a1bf3ec0fa2b2a43a88e037fbb