From 5e062ce86c87c0253fc237c6c26ed9d9293ef571 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Jun 2012 11:57:07 +1000 Subject: [PATCH] TONY: Properly free items during loading when there is duplicates --- engines/tony/mpal/loadmpc.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index e222891170b..bb2c9999841 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -421,6 +421,16 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { for (kk = 0; kk < curCmd; kk++) { if (compareCommands(&lpmiItem->_command[kk], &lpmiItem->_command[curCmd])) { lpmiItem->Action[i].CmdNum[j] = kk; + + // Free any data allocated for the duplictaed command + if (lpmiItem->_command[curCmd].type == 2) { + globalDestroy(lpmiItem->_command[curCmd].lpszVarName); + freeExpression(lpmiItem->_command[curCmd].expr); + + lpmiItem->_command[curCmd].lpszVarName = NULL; + lpmiItem->_command[curCmd].expr = 0; + lpmiItem->_command[curCmd].type = 0; + } break; } }