summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-27 13:05:48 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-27 13:05:48 +0000
commit20a2b656c2cbaac6585cf8bf7b8b4f37ad7877ba (patch)
tree9b5852e193960154282ce416a27a4b529f7b298c /string.c
parentf582b224bd4f86efc4230fb9819d0065cdf66a46 (diff)
* string.c (rb_str_inspect): get rid of adding garbage to short
UTF-8 string. [ruby-dev:39550] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@25515 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 6deb912921..fe7516892b 100644
--- a/string.c
+++ b/string.c
@@ -2718,8 +2718,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;
}