Preprocessor: Prevent (and give an error on) expression division by 0.

This commit is contained in:
John Kessenich 2015-07-20 12:29:41 -06:00
parent e9022e1ffe
commit d2762564dc
3 changed files with 19 additions and 1 deletions

View file

@ -505,6 +505,13 @@ int TPpContext::eval(int token, int precedence, bool shortCircuit, int& res, boo
token = scanToken(ppToken);
token = eval(token, binop[op].precedence, shortCircuit, res, err, ppToken);
if (binop[op].op == op_div || binop[op].op == op_mod) {
if (res == 0) {
parseContext.ppError(loc, "division by 0", "preprocessor evaluation", "");
res = 1;
}
}
res = binop[op].op(leftSide, res);
}