diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-08-04 12:25:14 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-08-04 12:25:14 +0900 |
| commit | 9cb44f5ae3bf36aa0c13a02b26a12217f5e6fc87 (patch) | |
| tree | f1d0f6d1c17a0aa40d3ca35a5129cd9ed5755655 | |
| parent | 9f377333825fe5ae00a6fa757da150bee5897b49 (diff) | |
| download | mruby-9cb44f5ae3bf36aa0c13a02b26a12217f5e6fc87.tar.gz mruby-9cb44f5ae3bf36aa0c13a02b26a12217f5e6fc87.zip | |
codegen.c: detect integer overflow in division.
`MRB_INT_MIN / -1` overflows.
| -rw-r--r-- | mrbgems/mruby-compiler/core/codegen.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c index 4dfe07faf..9915440dd 100644 --- a/mrbgems/mruby-compiler/core/codegen.c +++ b/mrbgems/mruby-compiler/core/codegen.c @@ -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); |
