aboutsummaryrefslogtreecommitdiffstats
path: root/numeric.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-02-24 09:39:17 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-02-24 09:39:17 +0000
commit7039d452827a25d1da4253d5318f451d27f34076 (patch)
tree294becc336406e7bc13844d9acde8dc8341bf36e /numeric.c
parenteaa095dc383eb0020a60e115f11bea9a55bdf6f9 (diff)
downloadruby-7039d452827a25d1da4253d5318f451d27f34076.tar.gz
Integer.sqrt argument check
* numeric.c (rb_int_s_isqrt): check if the argument is an integer. [Feature #13219] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57706 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/numeric.c b/numeric.c
index 2784b6dd86..b34fb0a5f9 100644
--- a/numeric.c
+++ b/numeric.c
@@ -5158,6 +5158,7 @@ static VALUE
rb_int_s_isqrt(VALUE self, VALUE num)
{
unsigned long n, sq;
+ num = rb_to_int(num);
if (FIXNUM_P(num)) {
if (FIXNUM_NEGATIVE_P(num)) {
domain_error("isqrt");
@@ -5166,7 +5167,7 @@ rb_int_s_isqrt(VALUE self, VALUE num)
sq = rb_ulong_isqrt(n);
return LONG2FIX(sq);
}
- if (RB_TYPE_P(num, T_BIGNUM)) {
+ else {
size_t biglen;
if (RBIGNUM_NEGATIVE_P(num)) {
domain_error("isqrt");
@@ -5183,7 +5184,6 @@ rb_int_s_isqrt(VALUE self, VALUE num)
#endif
return rb_big_isqrt(num);
}
- return Qnil;
}
/*