From 02cd93421dcedfdb2d3fd0005707e3d351368f1d Mon Sep 17 00:00:00 2001 From: Denis Kasak Date: Fri, 12 Jun 2009 11:32:44 +0000 Subject: Fixed evaluation of GPL mathematical expressions. The evaluator now checks that, at the end of the evaluation, the stack only contains one value (i.e. the result of the expression). svn-id: r41477 --- engines/draci/gpldisasm.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/engines/draci/gpldisasm.cpp b/engines/draci/gpldisasm.cpp index 17ed5c7494..ee7b128529 100644 --- a/engines/draci/gpldisasm.cpp +++ b/engines/draci/gpldisasm.cpp @@ -160,6 +160,10 @@ void handleMathExpression(Common::MemoryReadStream &reader) { uint16 value; while (1) { if (obj == kMathEnd) { + // Check whether the expression was evaluated correctly + // The stack should contain only one value after the evaluation + // i.e. the result of the expression + assert(stk.size() == 1 && "Mathematical expression error"); break; } @@ -177,6 +181,10 @@ void handleMathExpression(Common::MemoryReadStream &reader) { value = reader.readUint16LE(); stk.pop(); stk.pop(); + + // FIXME: Pushing dummy value for now, but should push return value + stk.push(0); + debugC(3, kDraciBytecodeDebugLevel, "\t\t-operator %s", operators[value-1].c_str()); break; @@ -189,6 +197,8 @@ void handleMathExpression(Common::MemoryReadStream &reader) { case kMathFunctionCall: value = reader.readUint16LE(); + + stk.pop(); // FIXME: Pushing dummy value for now, but should push return value stk.push(0); -- cgit v1.2.3