Added checks for divisiou and modulo by zero

This commit is contained in:
Kingcom 2013-06-29 16:24:26 +02:00
parent b78f74a3f4
commit b8d15838c5

View file

@ -382,9 +382,19 @@ bool parseExpression(char* infix, DebugInterface* cpu, u32& dest)
valueStack.push_back(arg[1]*arg[0]);
break;
case EXOP_DIV: // a/b
if (arg[0] == 0)
{
sprintf(expressionError,"Division by zero");
return false;
}
valueStack.push_back(arg[1]/arg[0]);
break;
case EXOP_MOD: // a%b
if (arg[0] == 0)
{
sprintf(expressionError,"Modulo by zero");
return false;
}
valueStack.push_back(arg[1]%arg[0]);
break;
case EXOP_ADD: // a+b