mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
codegen.c: -9223372036854775808 % -1 overflows 64 bit integer.
This commit is contained in:
@@ -824,11 +824,16 @@ gen_binop(codegen_scope *s, mrb_sym op, uint16_t dst)
|
||||
if (!mrb_num_shift(s->mrb, n0, -n, &n)) return FALSE;
|
||||
}
|
||||
else if (op == MRB_OPSYM_2(s->mrb, mod) && n != 0) {
|
||||
mrb_int n1 = n0 % n;
|
||||
if ((n0 < 0) != (n < 0) && n1 != 0) {
|
||||
n1 += n;
|
||||
if (n0 == MRB_INT_MIN && n == -1) {
|
||||
n = 0;
|
||||
}
|
||||
else {
|
||||
mrb_int n1 = n0 % n;
|
||||
if ((n0 < 0) != (n < 0) && n1 != 0) {
|
||||
n1 += n;
|
||||
}
|
||||
n = n1;
|
||||
}
|
||||
n = n1;
|
||||
}
|
||||
else if (op == MRB_OPSYM_2(s->mrb, and)) {
|
||||
n = n0 & n;
|
||||
|
||||
Reference in New Issue
Block a user