From 4b8e14c978bf1300b6528430c28aab21865a21f4 Mon Sep 17 00:00:00 2001 From: akr Date: Sun, 24 Jan 2010 04:59:31 +0000 Subject: [PATCH] * string.c (rb_enc_strlen_cr): increment by rb_enc_mbminlen(enc) for broken byte sequence. [ruby-core:27748] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26392 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ string.c | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) 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;