[Scummvm-tracker] [ScummVM :: Bugs] #15488: AGS: Crash when closing while there's an overlay open

ScummVM :: Bugs trac at scummvm.org
Tue Nov 26 18:55:54 UTC 2024


#15488: AGS: Crash when closing while there's an overlay open
-------------------------------+--------------------------
Reporter:  eriktorbjorn        |       Owner:  (none)
    Type:  defect              |      Status:  new
Priority:  high                |   Component:  Engine: AGS
 Version:                      |  Resolution:
Keywords:  ags crash overlays  |        Game:
-------------------------------+--------------------------
Comment (by bluegr):

 Here's some info I found:

 When closing the game while an overlay is shown, this is the sequence of
 events:
 - quit_free()
 - unload_game()
 - this calls _GP(spriteset).Reset()
 - GameSetupStruct::Free()
 - this calls SpriteInfos.clear() <---- this is important
 - AGSEngine() destructor
 - Globals() destructor
 - this resets g_globals to nullptr
 - this calls delete _screenover;
 - this calls free_dynamic_sprite()

 At this point, we got no globals, and SpriteInfos is empty, so this assert
 fails:

     assert((slot > 0) && (static_cast<size_t>(slot) <
 _GP(game).SpriteInfos.size()) &&
            (_GP(game).SpriteInfos[slot].Flags & SPF_DYNAMICALLOC));

 I tried moving the deletion of _screenover before g_globals is cleared,
 but SpriteInfos is empty.

 So, given the above, we can place this check at the top of
 free_dynamic_sprite(), which fixes the crash, and I believe it brings no
 memory leak, but I wanted an opinion first:

 if (!g_globals)
        return;
-- 
Ticket URL: <https://bugs.scummvm.org/ticket/15488#comment:5>
ScummVM :: Bugs <https://bugs.scummvm.org>
ScummVM


More information about the Scummvm-tracker mailing list