From 0616dd78d92e34066dc8a23a3158258c1d31921e Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 7 Jan 2015 11:43:47 +0300 Subject: [PATCH] math: don't divide or MOD by zero Just give up if you think you are dividing by zero. Signed-off-by: Dan Carpenter --- smatch_math.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/smatch_math.c b/smatch_math.c index 711626b6..5ac90621 100644 --- a/smatch_math.c +++ b/smatch_math.c @@ -457,6 +457,9 @@ static struct range_list *handle_implied_binop(struct expression *expr) FOR_EACH_PTR(left_rl, left_drange) { FOR_EACH_PTR(right_rl, right_drange) { + if ((expr->op == '%' || expr->op == '/') && + right_drange->min.value == 0) + return NULL; res = sval_binop(left_drange->min, expr->op, right_drange->min); add_range(&res_rl, res, res); } END_FOR_EACH_PTR(right_drange); -- 2.11.4.GIT