summaryrefslogtreecommitdiff
path: root/range.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-11 11:52:03 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-11 11:52:03 (GMT)
commit54bc0a446dd83c475c7ba540bccc1d9b3ad1e39a (patch)
tree97859b6c38e2fdc08e8483ad0a46096c783c43be /range.c
parente41ebc50dc27f5b91690295e0db8eaf45da42630 (diff)
range.c: check loading
* range.c (range_loader): check loading values if the data came from an initialized range object. [ruby-core:78067] [Bug #12915] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'range.c')
-rw-r--r--range.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/range.c b/range.c
index 6826499..422ed29 100644
--- a/range.c
+++ b/range.c
@@ -1231,14 +1231,19 @@ range_dumper(VALUE range)
static VALUE
range_loader(VALUE range, VALUE obj)
{
+ VALUE beg, end, excl;
+
if (!RB_TYPE_P(obj, T_OBJECT) || RBASIC(obj)->klass != rb_cObject) {
rb_raise(rb_eTypeError, "not a dumped range object");
}
range_modify(range);
- RANGE_SET_BEG(range, rb_ivar_get(obj, id_beg));
- RANGE_SET_END(range, rb_ivar_get(obj, id_end));
- RANGE_SET_EXCL(range, rb_ivar_get(obj, id_excl));
+ beg = rb_ivar_get(obj, id_beg);
+ end = rb_ivar_get(obj, id_end);
+ excl = rb_ivar_get(obj, id_excl);
+ if (!NIL_P(excl)) {
+ range_init(range, beg, end, RBOOL(RTEST(excl)));
+ }
return range;
}