Avoid division by zero in the preprocessor

Trac #15792 Issue=115 Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@566 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 125e2543
#define MAJOR_VERSION 0 #define MAJOR_VERSION 0
#define MINOR_VERSION 0 #define MINOR_VERSION 0
#define BUILD_VERSION 0 #define BUILD_VERSION 0
#define BUILD_REVISION 564 #define BUILD_REVISION 566
#define STRINGIFY(x) #x #define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x) #define MACRO_STRINGIFY(x) STRINGIFY(x)
......
...@@ -468,6 +468,17 @@ static int eval(int token, int prec, int *res, int *err, yystypepp * yylvalpp) ...@@ -468,6 +468,17 @@ static int eval(int token, int prec, int *res, int *err, yystypepp * yylvalpp)
val = *res; val = *res;
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
token = eval(token, binop[i].prec, res, err, yylvalpp); token = eval(token, binop[i].prec, res, err, yylvalpp);
if (binop[i].op == op_div || binop[i].op == op_mod)
{
if (*res == 0)
{
CPPErrorToInfoLog("preprocessor divide or modulo by zero");
*err = 1;
return token;
}
}
*res = binop[i].op(val, *res); *res = binop[i].op(val, *res);
} }
return token; return token;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment