Crash in SoldierGiveItemFromAnimation after winning in fight in San Mona

Issue #144 new
Lukas Jirkovsky created an issue

After winning a fight in San Mona, Darren is supposed to give the winner money. When this happens, the stack gets corrupted so badly that it is impossible to obtain stacktrace from gdb.

By using a signal handler and gcc's backtrace() function, I was able to track it down to:

Handle_Items.cc:2311

The problematic line itself is:

TempObject = *pSoldier->pTempObject;

Running it through gdb has shown that the SoldierGiveItemFromAnimation() is called twice, which looks fishy to me. The second call causes the crash.

Steps to reproduce

  1. Load the attached saved game
  2. End turn
  3. Wait for the dialog whether you want to continue fighting to appear
  4. Any answer causes the crash

Comments (2)

  1. Lukas Jirkovsky reporter

    Yep, it seems my suspicion was right, Darren tries to give me the money twice.

    I have commented out the following two lines that frees the memory and sets it to null which: * fixed the crash * caused Darren to give me 2 x $10,000 instead of just $10,000

    A quick fix is to add:

    if (!pSoldier->pTempObject)
        return;
    

    before the problematic line. However avoiding giving the money twice in the first place is probably a better solution.

  2. Log in to comment