From 44b607a0523847ed8913bb030fbfc77651cd7a92 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Sat, 12 Oct 2019 14:47:20 -0500 Subject: MOHAWK: RIVEN: Modify cursor preloading to resolve crashing on 3DS Common::PEResources being allocated on the stack was causing a stack overflow. ScummVM is configured to have 256kb of stack memory on the 3DS.--- engines/mohawk/cursors.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/engines/mohawk/cursors.cpp b/engines/mohawk/cursors.cpp index 2cb41be65e..12c3ebfffe 100644 --- a/engines/mohawk/cursors.cpp +++ b/engines/mohawk/cursors.cpp @@ -242,19 +242,21 @@ void LivingBooksCursorManager_v2::setCursor(const Common::String &name) { } PECursorManager::PECursorManager(const Common::String &appName) { - Common::PEResources exe; - if (!exe.loadFromEXE(appName)) { + Common::PEResources *exe = new Common::PEResources(); + if (!exe->loadFromEXE(appName)) { // Not all have cursors anyway, so this is not a problem return; } - const Common::Array cursorGroups = exe.getNameList(Common::kWinGroupCursor); + const Common::Array cursorGroups = exe->getNameList(Common::kWinGroupCursor); _cursors.resize(cursorGroups.size()); for (uint i = 0; i < cursorGroups.size(); i++) { _cursors[i].id = cursorGroups[i].getID(); - _cursors[i].cursorGroup = Graphics::WinCursorGroup::createCursorGroup(exe, cursorGroups[i]); + _cursors[i].cursorGroup = Graphics::WinCursorGroup::createCursorGroup(*exe, cursorGroups[i]); } + + delete exe; } PECursorManager::~PECursorManager() { -- cgit v1.2.3