Rational denominator should not be zero.

parent c7d96dbf
......@@ -135,6 +135,9 @@ rational_new_i(mrb_state *mrb, mrb_int n, mrb_int d)
{
mrb_int a;
if (d == 0) {
mrb_raise(mrb, E_ZERODIV_ERROR, "divided by 0 in rational");
}
a = i_gcd(n, d);
if ((n == MRB_INT_MIN || d == MRB_INT_MIN) && a == -1) {
mrb_raise(mrb, E_RANGE_ERROR, "integer overflow in rational");
......
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