summaryrefslogtreecommitdiff
path: root/regenc.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-08-13 06:37:39 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-08-13 06:37:39 +0000
commit3711c63b6a2513348a4dc991ec25198244636d2a (patch)
treed1fee1634a9ada1310d01daf811987f055ab0d85 /regenc.c
parent579edea3c91f5f5ca1475b845729c0a63a99cfd7 (diff)
downloadruby-3711c63b6a2513348a4dc991ec25198244636d2a.tar.gz
* regenc.c (onigenc_strlen_null, onigenc_str_bytelen_null): fixed
infinite loop for wide encodings. reported by Ralf Junker at [ruby-core:24892]. [ruby-core:24904] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24521 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'regenc.c')
-rw-r--r--regenc.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/regenc.c b/regenc.c
index bb180367da..065e4d298a 100644
--- a/regenc.c
+++ b/regenc.c
@@ -136,7 +136,7 @@ onigenc_strlen_null(OnigEncoding enc, const UChar* s)
{
int n = 0;
UChar* p = (UChar* )s;
- UChar* e = p + strlen((const char *)s);
+ UChar* e;
while (1) {
if (*p == '\0') {
@@ -152,6 +152,7 @@ onigenc_strlen_null(OnigEncoding enc, const UChar* s)
}
if (len == 1) return n;
}
+ e = p + ONIGENC_MBC_MAXLEN(enc);
p += ONIGENC_MBC_ENC_LEN(enc, p, e);
n++;
}
@@ -162,7 +163,7 @@ onigenc_str_bytelen_null(OnigEncoding enc, const UChar* s)
{
UChar* start = (UChar* )s;
UChar* p = (UChar* )s;
- UChar* e = p + strlen((const char *)s);
+ UChar* e;
while (1) {
if (*p == '\0') {
@@ -178,6 +179,7 @@ onigenc_str_bytelen_null(OnigEncoding enc, const UChar* s)
}
if (len == 1) return (int )(p - start);
}
+ e = p + ONIGENC_MBC_MAXLEN(enc);
p += ONIGENC_MBC_ENC_LEN(enc, p, e);
}
}