summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-13 09:04:32 (GMT)
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-13 09:04:32 (GMT)
commit48de2ea5f9b9067779acb0f7f76e5f879f2b42c0 (patch)
tree8fc7b7396059745163a8d4c224c82647da9345e5 /compile.c
parent75d25ede15e664ee0048ebc4e84e9e34838c2313 (diff)
range.c: prohibit `(1..nil)`
Now endless range can be created by either a literal `(1..)` or explicit range creation `Range.new(1, nil)`. [Bug #14845] This change is intended for "early failure"; for example, `(1..var).to_a` causes out of memory if `var` is inadvertently nil. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/compile.c b/compile.c
index 2197183..2caf92e 100644
--- a/compile.c
+++ b/compile.c
@@ -7188,10 +7188,10 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
case NODE_DOT2:
case NODE_DOT3:{
int excl = type == NODE_DOT3;
- VALUE flag = INT2FIX(excl);
const NODE *b = node->nd_beg;
const NODE *e = node->nd_end;
- if (number_literal_p(b) && number_literal_p(e)) {
+ VALUE flag = INT2FIX(excl | (e ? 0 : 2));
+ if (number_literal_p(b) && e && number_literal_p(e)) {
if (!popped) {
VALUE val = rb_range_new(b->nd_lit, e->nd_lit, excl);
iseq_add_mark_object_compile_time(iseq, val);