diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-01-13 09:17:20 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-01-13 09:17:20 +0900 |
| commit | a639a39883f95365e8f336cd4770c06f3d9aa87a (patch) | |
| tree | dfc0914eb319d98f443b3c5db445c8ddb21a1d5f /mrbgems/mruby-rational/src | |
| parent | c7d96dbf84e0fab1a84b3589a7f557aa3878211e (diff) | |
| download | mruby-a639a39883f95365e8f336cd4770c06f3d9aa87a.tar.gz mruby-a639a39883f95365e8f336cd4770c06f3d9aa87a.zip | |
Rational denominator should not be zero.
Diffstat (limited to 'mrbgems/mruby-rational/src')
| -rw-r--r-- | mrbgems/mruby-rational/src/rational.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/mrbgems/mruby-rational/src/rational.c b/mrbgems/mruby-rational/src/rational.c index 5e25bfb99..c63769a31 100644 --- a/mrbgems/mruby-rational/src/rational.c +++ b/mrbgems/mruby-rational/src/rational.c @@ -135,6 +135,9 @@ rational_new_i(mrb_state *mrb, mrb_int n, mrb_int d) { mrb_int a; + if (d == 0) { + mrb_raise(mrb, E_ZERODIV_ERROR, "divided by 0 in rational"); + } a = i_gcd(n, d); if ((n == MRB_INT_MIN || d == MRB_INT_MIN) && a == -1) { mrb_raise(mrb, E_RANGE_ERROR, "integer overflow in rational"); |
