Fix `mrb_int_mul_overflow()` to check either operand being zero.
MODIFY
include/mruby/numeric.h
include/mruby/numeric.h
@@ -136,15 +136,15 @@ mrb_int_mul_overflow(mrb_int multiplier, mrb_int multiplicand, mrb_int *product)
if (multiplicand > 0) {
if (multiplier > MRB_INT_MAX / multiplicand) return TRUE;
}
- else {
+ else if (multiplicand < 0) {
if (multiplicand < MRB_INT_MAX / multiplier) return TRUE;
}
}
- else {
+ else if (multiplier < 0) {
if (multiplicand > 0) {
if (multiplier < MRB_INT_MAX / multiplicand) return TRUE;
}
- else {
+ else if (multiplicand < 0) {
if (multiplier != 0 && multiplicand < MRB_INT_MAX / multiplier) return TRUE;
}
}

MODIFY
mrbgems/mruby-sprintf/src/sprintf.c
mrbgems/mruby-sprintf/src/sprintf.c
@@ -1082,7 +1082,7 @@ retry:
need = width;
if (need < 0) {
- mrb_raise(mrb, E_ARGUMENT_ERROR, "width too big 2");
+ mrb_raise(mrb, E_ARGUMENT_ERROR, "width too big");
}
FILL(' ', need);
if (flags & FMINUS) {
@@ -1108,7 +1108,7 @@ retry:
if (need > MRB_INT_MAX - ((flags&FPREC) ? prec : 6)) {
too_big_width:
mrb_raise(mrb, E_ARGUMENT_ERROR,
- (width > prec ? "width too big 3" : "prec too big"));
+ (width > prec ? "width too big" : "prec too big"));
}
need += (flags&FPREC) ? prec : 6;
if ((flags&FWIDTH) && need < width)

Fix `mrb_int_mul_overflow()` to check either operand being zero.