From be34e31d8e68b365a104c955389c6e9f865e054e Mon Sep 17 00:00:00 2001 From: Kenta Murata Date: Sat, 9 Jan 2021 15:19:52 +0900 Subject: [ruby/bigdecimal] Add assertions for checking the argument types https://github.com/ruby/bigdecimal/commit/96c9ebd886 --- ext/bigdecimal/bigdecimal.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'ext') 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; -- cgit v1.2.3