[Scummvm-tracker] [ScummVM :: Bugs] #14493: XEEN: Coin of Daily &use magic items crashes game

ScummVM :: Bugs trac at scummvm.org
Sun Jun 4 23:18:09 UTC 2023


#14493: XEEN: Coin of Daily &use magic items crashes game
-------------------------+---------------------------------------------
Reporter:  IvoryTower33  |       Owner:  dreammaster
    Type:  defect        |      Status:  new
Priority:  normal        |   Component:  Engine: Xeen
 Version:                |  Resolution:
Keywords:                |        Game:  Might and Magic: World of Xeen
-------------------------+---------------------------------------------
Comment (by PushmePullyu):

 Tested with master !c77e9f8cae261673478fbf071401c767995a3b24.

 This seems to be caused by a stale pointer dereference when a spell uses
 combat._oldCharacter.

 dialogs/dialogs_items.cpp:
 {{{
 int ItemsDialog::doItemOptions(...) {
 ...
     _oldCharacter = &c;
     // FIXME: Some spells use combat._oldCharacter, and it may not be set
     // if an item is used directly after the game is started
     if (!combat._oldCharacter)
         combat._oldCharacter = &c;
 ...
 }
 }}}
 If combat._oldCharacter was set before and a new game is loaded the check
 will fail and it will not be reset. A possible fix would be to reset
 combat._oldCharacter to nullptr when loading a game (e.g. in
 Combat::setupCombatParty()).

 To reproduce:
 1. Load slot 23: "dasd" (from the provided save)
 2. Use the "Coin of daily sorcerery" (sic)
 3. Load slot 23 again
 4. Use the coin again

 This should either trigger a crash or an invalid memory access when using
 an address sanitizer like Valgrind.
-- 
Ticket URL: <https://bugs.scummvm.org/ticket/14493#comment:6>
ScummVM :: Bugs <https://bugs.scummvm.org>
ScummVM


More information about the Scummvm-tracker mailing list