summaryrefslogtreecommitdiffhomepage
path: root/src/numeric.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2021-08-03 16:45:08 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2021-08-03 16:45:08 +0900
commit9b3b2a4c957bbeb0b65978e8075c348cdecda44f (patch)
tree4c1e0a4ad82b93ed123455ba9c92d5e088cda4e7 /src/numeric.c
parentcaaa07f2da8800867a9c661fb3c63d93f63c15c7 (diff)
downloadmruby-9b3b2a4c957bbeb0b65978e8075c348cdecda44f.tar.gz
mruby-9b3b2a4c957bbeb0b65978e8075c348cdecda44f.zip
numeric.c: check zero division before modulo.
Diffstat (limited to 'src/numeric.c')
-rw-r--r--src/numeric.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/numeric.c b/src/numeric.c
index ca39e318e..dd06d8115 100644
--- a/src/numeric.c
+++ b/src/numeric.c
@@ -1118,6 +1118,7 @@ int_mod(mrb_state *mrb, mrb_value x)
a = mrb_integer(x);
if (mrb_integer_p(y) && a != MRB_INT_MIN && (b=mrb_integer(y)) != MRB_INT_MIN) {
+ if (b == 0) int_zerodiv(mrb);
mrb_int mod = a % b;
if ((a < 0) != (b < 0) && mod != 0) {
mod += b;