Fix infinite recursive call bugs in integer division.
MODIFY
mrbgems/mruby-complex/src/complex.c
mrbgems/mruby-complex/src/complex.c
@@ -304,6 +304,7 @@ int_div(mrb_state *mrb, mrb_value x)
}
switch (mrb_type(y)) {
case MRB_TT_COMPLEX:
+ x = complex_new(mrb, (mrb_float)a, 0);
return mrb_funcall_id(mrb, x, MRB_OPSYM(div), 1, y);
default:
return mrb_float_value(mrb, (mrb_float)a * mrb_to_flo(mrb, y));
@@ -323,6 +324,7 @@ int_quo(mrb_state *mrb, mrb_value x)
switch (mrb_type(y)) {
case MRB_TT_COMPLEX:
+ x = complex_new(mrb, (mrb_float)a, 0);
return mrb_funcall_id(mrb, x, MRB_OPSYM(div), 1, y);
default:
return mrb_float_value(mrb, (mrb_float)a * mrb_to_flo(mrb, y));

MODIFY
mrbgems/mruby-rational/src/rational.c
mrbgems/mruby-rational/src/rational.c
@@ -428,6 +428,7 @@ int_div(mrb_state *mrb, mrb_value x)
return mrb_funcall_id(mrb, x, MRB_OPSYM(div), 1, y);
#if defined(MRB_USE_COMPLEX)
case MRB_TT_COMPLEX:
+ x = mrb_complex_new(mrb, (mrb_float)a, 0);
return mrb_funcall_id(mrb, x, MRB_OPSYM(div), 1, y);
#endif
case MRB_TT_FLOAT:
@@ -460,6 +461,7 @@ int_quo(mrb_state *mrb, mrb_value x)
return mrb_funcall_id(mrb, x, MRB_OPSYM(div), 1, y);
#if defined(MRB_USE_COMPLEX)
case MRB_TT_COMPLEX:
+ x = mrb_complex_new(mrb, (mrb_float)a, 0);
return mrb_funcall_id(mrb, x, MRB_OPSYM(div), 1, y);
#endif
default:

Fix infinite recursive call bugs in integer division.