aboutsummaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
authorKenta Murata <mrkn@mrkn.jp>2021-01-09 15:19:52 +0900
committerKenta Murata <mrkn@mrkn.jp>2021-01-09 20:36:18 +0900
commitbe34e31d8e68b365a104c955389c6e9f865e054e (patch)
tree79472f5f49529503d7abfe3e3aa7f069f6bca72e /ext
parentfb18a8113a549185938e3cf12b3494547d077558 (diff)
downloadruby-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.c4
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;