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

parent 4dcc1819
......@@ -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;
}
}
......
......@@ -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)
......
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