mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-19 08:25:35 +00:00
ANDROID: Avoid use-after-free when setting up touch mode
We set up touch mode in graphics managers constructor. At this point, the _graphicsManager variable was pointed to the freshly deleted old manager instead of being null. When we are in this position, assume the cursor is at top left.
This commit is contained in:
parent
fe5fddd37e
commit
3a57523490
@ -970,6 +970,7 @@ bool OSystem_Android::setGraphicsMode(int mode, uint flags) {
|
||||
if (render3d && !supports3D) {
|
||||
debug(5, "switching to 3D graphics");
|
||||
delete _graphicsManager;
|
||||
_graphicsManager = nullptr;
|
||||
AndroidGraphics3dManager *manager = new AndroidGraphics3dManager();
|
||||
_graphicsManager = manager;
|
||||
androidGraphicsManager = manager;
|
||||
@ -977,6 +978,7 @@ bool OSystem_Android::setGraphicsMode(int mode, uint flags) {
|
||||
} else if (!render3d && supports3D) {
|
||||
debug(5, "switching to 2D graphics");
|
||||
delete _graphicsManager;
|
||||
_graphicsManager = nullptr;
|
||||
AndroidGraphicsManager *manager = new AndroidGraphicsManager();
|
||||
_graphicsManager = manager;
|
||||
androidGraphicsManager = manager;
|
||||
|
@ -1541,7 +1541,12 @@ void OSystem_Android::setupTouchMode(int oldValue, int newValue) {
|
||||
|
||||
if (newValue == TOUCH_MODE_TOUCHPAD) {
|
||||
// Make sure we have a proper touch point if we switch to touchpad mode with finger down
|
||||
_touch_pt_down = dynamic_cast<AndroidCommonGraphics *>(_graphicsManager)->getMousePosition();
|
||||
if (_graphicsManager) {
|
||||
_touch_pt_down = dynamic_cast<AndroidCommonGraphics *>(_graphicsManager)->getMousePosition();
|
||||
} else {
|
||||
_touch_pt_down.x = 0;
|
||||
_touch_pt_down.y = 0;
|
||||
}
|
||||
_touch_pt_scroll.x = -1;
|
||||
_touch_pt_scroll.y = -1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user