summaryrefslogtreecommitdiff
path: root/range.c
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-21 04:23:56 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-21 04:23:56 +0000
commit165da0da2f185cab12ba68214de3b4f4ab81a46a (patch)
tree315ad2aa5dbb6bf5efe65641b175911d663182a8 /range.c
parentb317bf06a4d8200b43d46685e251e993241e0765 (diff)
* range.c (rb_range_beg_len): Fix potential bug for limit case [#6203]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'range.c')
-rw-r--r--range.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/range.c b/range.c
index 42fac03..3e0817b 100644
--- a/range.c
+++ b/range.c
@@ -1076,16 +1076,16 @@ rb_range_beg_len(VALUE range, long *begp, long *lenp, long len, int err)
if (beg < 0)
goto out_of_range;
}
+ if (end < 0)
+ end += len;
+ if (!excl)
+ end++; /* include end point */
if (err == 0 || err == 2) {
if (beg > len)
goto out_of_range;
if (end > len)
end = len;
}
- if (end < 0)
- end += len;
- if (!excl)
- end++; /* include end point */
len = end - beg;
if (len < 0)
len = 0;