summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-02 08:41:13 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-02 08:41:13 +0000
commit7c26006a21f2f34bec739a074bf46ed429fcee79 (patch)
tree1e8fee6e140a3264fc3b758aea27b7557dfeb1c1 /ext
parent1b5e93c6f3d83852b633e7b087a706d6760ad0c4 (diff)
merge revision(s) 16851:
* ext/iconv/iconv.c (iconv_iconv): fixed backport miss. [ruby-core:17115] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@17791 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/iconv/iconv.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
index 4736cb1008..4674aa330e 100644
--- a/ext/iconv/iconv.c
+++ b/ext/iconv/iconv.c
@@ -755,7 +755,12 @@ iconv_iconv
if (!NIL_P(str)) slen = RSTRING_LEN(StringValue(str));
if (argc != 2 || !RTEST(rb_range_beg_len(n1, &start, &length, slen, 0))) {
if (NIL_P(n1) || ((start = NUM2LONG(n1)) < 0 ? (start += slen) >= 0 : start < slen)) {
- if (!NIL_P(n2)) length = NUM2LONG(n2);
+ if (NIL_P(n2)) {
+ length = -1;
+ }
+ else if ((length = NUM2LONG(n2)) >= slen - start) {
+ length = slen - start;
+ }
}
}