diff options
author | Kenta Murata <mrkn@mrkn.jp> | 2021-01-09 15:19:52 +0900 |
---|---|---|
committer | Kenta Murata <mrkn@mrkn.jp> | 2021-01-09 20:36:18 +0900 |
commit | be34e31d8e68b365a104c955389c6e9f865e054e (patch) | |
tree | 79472f5f49529503d7abfe3e3aa7f069f6bca72e /ext | |
parent | fb18a8113a549185938e3cf12b3494547d077558 (diff) | |
download | ruby-be34e31d8e68b365a104c955389c6e9f865e054e.tar.gz |
[ruby/bigdecimal] Add assertions for checking the argument types
https://github.com/ruby/bigdecimal/commit/96c9ebd886
Diffstat (limited to 'ext')
-rw-r--r-- | ext/bigdecimal/bigdecimal.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index 5194615475..ef17882db1 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -2799,6 +2799,8 @@ static VALUE rb_rational_convert_to_BigDecimal(VALUE val, size_t digs, int raise static VALUE rb_float_convert_to_BigDecimal(VALUE val, size_t digs, int raise_exception) { + assert(RB_FLOAT_TYPE_P(val)); + double d = RFLOAT_VALUE(val); if (!isfinite(d)) { @@ -2838,6 +2840,8 @@ rb_float_convert_to_BigDecimal(VALUE val, size_t digs, int raise_exception) static VALUE rb_rational_convert_to_BigDecimal(VALUE val, size_t digs, int raise_exception) { + assert(RB_TYPE_P(val, T_RATIONAL)); + if (digs == SIZE_MAX) { if (!raise_exception) return Qnil; |