diff options
| author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-06 03:20:36 +0000 |
|---|---|---|
| committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-06 03:20:36 +0000 |
| commit | bff8ab13f33c59ffed9fcf397a60e26fc376d1ed (patch) | |
| tree | d359d486b84bb616f550f7524acefbfa1bbce6f2 /ext | |
| parent | 3c964ddb71a670f47500892dac704b3185ab72b4 (diff) | |
* 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@16851 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
| -rw-r--r-- | ext/iconv/iconv.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c index 72ecc750f4..d989b97df2 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; + } } } |
