diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-08-03 16:43:50 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-08-03 16:43:50 +0900 |
| commit | caaa07f2da8800867a9c661fb3c63d93f63c15c7 (patch) | |
| tree | 7c7fb76b762c7fa3c14400e67095ab15b83627b9 /mrbgems/mruby-compiler | |
| parent | c480ac4457d026593c50f6c2704ac74f9255b2f0 (diff) | |
| download | mruby-caaa07f2da8800867a9c661fb3c63d93f63c15c7.tar.gz mruby-caaa07f2da8800867a9c661fb3c63d93f63c15c7.zip | |
codegen.c: check zero division before constant folding.
Diffstat (limited to 'mrbgems/mruby-compiler')
| -rw-r--r-- | mrbgems/mruby-compiler/core/codegen.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c index 0a0620589..4dfe07faf 100644 --- a/mrbgems/mruby-compiler/core/codegen.c +++ b/mrbgems/mruby-compiler/core/codegen.c @@ -822,7 +822,7 @@ gen_binop(codegen_scope *s, mrb_sym op, uint16_t dst) if (n == MRB_INT_MIN) return FALSE; if (!mrb_num_shift(s->mrb, n0, -n, &n)) return FALSE; } - else if (op == MRB_OPSYM_2(s->mrb, mod)) { + 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; |
