mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
numeric.c (int_pow): should not overflow.
This commit is contained in:
@@ -85,7 +85,11 @@ mrb_int_pow(mrb_state *mrb, mrb_value x)
|
||||
for (;;) {
|
||||
if (exp & 1) {
|
||||
if (mrb_int_mul_overflow(result, base, &result)) {
|
||||
#ifdef MRB_USE_BIGINT
|
||||
return mrb_bint_pow(mrb, mrb_bint_new_int(mrb, mrb_integer(x)), y);
|
||||
#else
|
||||
mrb_int_overflow(mrb, "power");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
exp >>= 1;
|
||||
|
||||
Reference in New Issue
Block a user