codegen.c: detect integer overflow in division.

`MRB_INT_MIN / -1` overflows.
This commit is contained in:
Yukihiro "Matz" Matsumoto
2021-08-04 12:25:14 +09:00
parent 9f37733382
commit 9cb44f5ae3
+1
View File
@@ -791,6 +791,7 @@ gen_muldiv(codegen_scope *s, uint8_t op, uint16_t dst)
if (mrb_int_mul_overflow(n0, n, &n)) goto normal;
}
else { /* OP_DIV */
if (n0 == MRB_INT_MIN && n == -1) goto normal;
n = n0 / n;
}
s->pc = addr_pc(s, data0.addr);