summaryrefslogtreecommitdiff
path: root/random.c
diff options
context:
space:
mode:
Diffstat (limited to 'random.c')
-rw-r--r--random.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/random.c b/random.c
index 6a42e24..cfd2f62 100644
--- a/random.c
+++ b/random.c
@@ -851,7 +851,7 @@ rb_random_ulong_limited(VALUE obj, unsigned long limit)
if (!rnd) {
extern int rb_num_negative_p(VALUE);
VALUE lim = ulong_to_num_plus_1(limit);
- VALUE v = rb_funcall2(obj, id_rand, 1, &lim);
+ VALUE v = rb_to_int(rb_funcall2(obj, id_rand, 1, &lim));
unsigned long r = NUM2ULONG(v);
if (rb_num_negative_p(v)) {
rb_raise(rb_eRangeError, "random number too small %ld", r);