From ad949e8f31ac43a1805716dfb6382bbdaa0d9ec1 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 9 May 2016 03:52:09 +0000 Subject: [PATCH] random.c: seed conversion * random.c (rand_init): random_seed() always returns an Integer, no conversion for it. * random.c (random_init, rb_f_srand): convert the given seed to an Integer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- random.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/random.c b/random.c index cff5ea85e8..b5f6c18dfe 100644 --- a/random.c +++ b/random.c @@ -368,8 +368,6 @@ rand_init(struct MT *mt, VALUE seed) size_t len; int sign; - seed = rb_to_int(seed); - len = rb_absint_numwords(seed, 32, NULL); if (len > numberof(buf0)) buf = ALLOC_N(uint32_t, len); @@ -415,6 +413,7 @@ random_init(int argc, VALUE *argv, VALUE obj) else { vseed = argv[0]; rb_check_copyable(obj, vseed); + vseed = rb_to_int(vseed); } rnd->seed = rand_init(&rnd->mt, vseed); return obj; @@ -784,7 +783,7 @@ rb_f_srand(int argc, VALUE *argv, VALUE obj) seed = random_seed(); } else { - seed = argv[0]; + seed = rb_to_int(argv[0]); } old = r->seed; r->seed = rand_init(&r->mt, seed);