diff options
author | Eugene Sandulenko | 2016-01-07 00:26:12 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2016-01-07 00:26:12 +0100 |
commit | 6b428f211c45bbc3ef829b0032cb18d335408bce (patch) | |
tree | 23488c9484f2727ec024718856e036ee2fe70856 /engines/wage | |
parent | 28a02b820061bd2d344f273dce54e562cf5b1fa1 (diff) | |
download | scummvm-rg350-6b428f211c45bbc3ef829b0032cb18d335408bce.tar.gz scummvm-rg350-6b428f211c45bbc3ef829b0032cb18d335408bce.tar.bz2 scummvm-rg350-6b428f211c45bbc3ef829b0032cb18d335408bce.zip |
WAGE: Fix numerpous memory leaks
Diffstat (limited to 'engines/wage')
-rw-r--r-- | engines/wage/script.cpp | 16 | ||||
-rw-r--r-- | engines/wage/script.h | 5 |
2 files changed, 19 insertions, 2 deletions
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp index ec3f7b2115..5bc1bb74f1 100644 --- a/engines/wage/script.cpp +++ b/engines/wage/script.cpp @@ -119,6 +119,7 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i Operand *op = readOperand(); // TODO check op type is string or number, or something good... appendText(op->toString()); + delete op; byte d = _data->readByte(); if (d != 0xFD) warning("Operand 0x8B (PRINT) End Byte != 0xFD"); @@ -130,6 +131,7 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i // TODO check op type is string. _handled = true; callbacks->playSound(op->toString()); + delete op; byte d = _data->readByte(); if (d != 0xFD) warning("Operand 0x8B (PRINT) End Byte != 0xFD"); @@ -449,6 +451,9 @@ void Script::processIf() { bool condResult = eval(lhs, op, rhs); + delete lhs; + delete rhs; + if (logicalOp == 1) { result = (result && condResult); } else if (logicalOp == 2) { @@ -475,9 +480,12 @@ void Script::processIf() { void Script::skipIf() { do { - readOperand(); + Operand *lhs = readOperand(); readOperator(); - readOperand(); + Operand *rhs = readOperand(); + + delete lhs; + delete rhs; } while (_data->readByte() != 0xFE); } @@ -884,6 +892,9 @@ void Script::processMove() { error("No end for MOVE: %02x", skip); evaluatePair(what, "M", to); + + delete what; + delete to; } void Script::processLet() { @@ -904,6 +915,7 @@ void Script::processLet() { Operand *operand = readOperand(); // TODO assert that value is NUMBER int16 value = operand->_value.number; + delete operand; if (lastOp != NULL) { if (lastOp[0] == '+') result += value; diff --git a/engines/wage/script.h b/engines/wage/script.h index 5bd26adad0..adb18132b2 100644 --- a/engines/wage/script.h +++ b/engines/wage/script.h @@ -109,6 +109,11 @@ private: _type = type; } + ~Operand() { + if (_type == STRING) + delete _value.string; + } + Common::String toString() { char buf[128]; |