summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-12-13 15:59:51 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-12-13 15:59:51 +0000
commit6de1532775ec9802acc71c2c8b21794309b479b9 (patch)
treed2bae3abf015e991aa3be3d729f4eb3109ca7fd2 /string.c
parentcf6247135b197aa3951cd70e9e7219149c2f520a (diff)
merge revision(s) 25515:
* string.c (rb_str_inspect): get rid of adding garbage to shor UTF-8 string. [ruby-dev:39550] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@26078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/string.c b/string.c
index 4de0954a46..69430c6cfc 100644
--- a/string.c
+++ b/string.c
@@ -2641,8 +2641,8 @@ rb_str_inspect(str)
p = RSTRING(str)->ptr; pend = p + RSTRING(str)->len;
while (p < pend) {
char c = *p++;
- if (ismbchar(c) && p < pend) {
- int len = mbclen(c);
+ int len;
+ if (ismbchar(c) && p + (len = mbclen(c)) <= pend) {
rb_str_buf_cat(result, p - 1, len);
p += len - 1;
}