diff --git a/ChangeLog b/ChangeLog index 6393b68348..87f22ba702 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Jan 24 13:55:54 2010 Tanaka Akira + + * string.c (rb_enc_strlen_cr): increment by rb_enc_mbminlen(enc) for + broken byte sequence. [ruby-core:27748] + Sun Jan 24 05:18:34 2010 Nobuyoshi Nakada * thread.c (thread_start_func_2): unlock all locking mutexes diff --git a/string.c b/string.c index 0bd1ca80cc..6addc621ee 100644 --- a/string.c +++ b/string.c @@ -1008,7 +1008,10 @@ rb_enc_strlen_cr(const char *p, const char *e, rb_encoding *enc, int *cr) } else { *cr = ENC_CODERANGE_BROKEN; - p++; + if (p + rb_enc_mbminlen(enc) <= e) + p += rb_enc_mbminlen(enc); + else + p = e; } } if (!*cr) *cr = ENC_CODERANGE_7BIT;