summaryrefslogtreecommitdiff
path: root/random.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-03 06:31:22 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-03 06:31:22 (GMT)
commit64712906b063d5470f74ef0b19d16e4aa84defdf (patch)
tree54c0eaa1d886580539e070806ef970bf59649612 /random.c
parent4cef2c8d6b61cc517191da781f777306823a05cb (diff)
random.c: endless range random
* random.c (range_values): cannot determine the domain of an endless range. [ruby-core:88261] [Bug #14958] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'random.c')
-rw-r--r--random.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/random.c b/random.c
index 7165f3c..75ad5ff 100644
--- a/random.c
+++ b/random.c
@@ -302,6 +302,7 @@ VALUE rb_cRandom;
#define id_minus '-'
#define id_plus '+'
static ID id_rand, id_bytes;
+NORETURN(static void domain_error(void));
/* :nodoc: */
static void
@@ -1163,6 +1164,7 @@ range_values(VALUE vmax, VALUE *begp, VALUE *endp, int *exclp)
if (!rb_range_values(vmax, begp, &end, exclp)) return Qfalse;
if (endp) *endp = end;
+ if (NIL_P(end)) domain_error();
if (!rb_respond_to(end, id_minus)) return Qfalse;
r = rb_funcallv(end, id_minus, 1, begp);
if (NIL_P(r)) return Qfalse;
@@ -1205,7 +1207,6 @@ rand_int(VALUE obj, rb_random_t *rnd, VALUE vmax, int restrictive)
}
}
-NORETURN(static void domain_error(void));
static void
domain_error(void)
{