Avoid `MRB_INT_MIN` to apply `fixdivmod`.

`MRB_INT_MIN` is the only integer value that has no corresponding
positive integer value (i.e. `-MRB_INT_MIN` = `MRB_INT_MIN`).
parent c31e1ea7
...@@ -891,14 +891,14 @@ static mrb_value ...@@ -891,14 +891,14 @@ static mrb_value
fix_mod(mrb_state *mrb, mrb_value x) fix_mod(mrb_state *mrb, mrb_value x)
{ {
mrb_value y; mrb_value y;
mrb_int a; mrb_int a, b;
mrb_get_args(mrb, "o", &y); mrb_get_args(mrb, "o", &y);
a = mrb_fixnum(x); a = mrb_fixnum(x);
if (mrb_fixnum_p(y)) { if (mrb_fixnum_p(y) && a != MRB_INT_MIN && (b=mrb_fixnum(y)) != MRB_INT_MIN) {
mrb_int b, mod; mrb_int mod;
if ((b=mrb_fixnum(y)) == 0) { if (b == 0) {
#ifdef MRB_WITHOUT_FLOAT #ifdef MRB_WITHOUT_FLOAT
/* ZeroDivisionError */ /* ZeroDivisionError */
return mrb_fixnum_value(0); return mrb_fixnum_value(0);
......
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