aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-27 11:09:41 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-27 11:09:41 +0000
commitb8b0f6fd46840d90a22d2c75bf823d31aa62cc18 (patch)
tree13b8b1c22617281c85e378114a7957820465e645 /string.c
parent36b4d1a1dc0a160a08994fd6f165b46863ecc65b (diff)
downloadruby-b8b0f6fd46840d90a22d2c75bf823d31aa62cc18.tar.gz
* string.c (rb_str_inspect): avoid exception by
"\#\xa1".force_encoding("euc-jp").inspect. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15272 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/string.c b/string.c
index 168e7a6b82..452e4affc1 100644
--- a/string.c
+++ b/string.c
@@ -3311,9 +3311,11 @@ rb_str_inspect(VALUE str)
p += n;
if (c == '"'|| c == '\\' ||
- (c == '#' && p < pend &&
- (cc = rb_enc_codepoint(p,pend,enc),
- (cc == '$' || cc == '@' || cc == '{')))) {
+ (c == '#' &&
+ p < pend &&
+ MBCLEN_CHARFOUND(rb_enc_precise_mbclen(p,pend,enc)) &&
+ (cc = rb_enc_codepoint(p,pend,enc),
+ (cc == '$' || cc == '@' || cc == '{')))) {
prefix_escape(result, c, enc);
}
else if (c == '\n') {