Catch divide-by-zero in ${eval:...}.
[exim.git] / src / src / expand.c
index bf425ae81ed6a031378a6f1a3bcb9d48d953d061..06e0eb0ced0d6dd09124c67242aabe00699cb88b 100644 (file)
@@ -3107,7 +3107,16 @@ if (*error == NULL)
     int y = eval_op_unary(&s, decimal, error);
     if (*error != NULL) break;
     if (op == '*') x *= y;
-      else if (op == '/') x /= y;
+      else if (op == '/')
+        {
+        if (y == 0)
+          {
+          *error = US"divide by zero";
+          x = 0;
+          break;
+          }
+        x /= y;
+        }
       else x %= y;
     }
   }