1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
nobu 2009-08-13 06:37:39 +00:00
parent 579edea3c9
commit 3711c63b6a
2 changed files with 10 additions and 2 deletions

View file

@ -1,3 +1,9 @@
Thu Aug 13 15:37:33 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* regenc.c (onigenc_strlen_null, onigenc_str_bytelen_null): fixed
infinite loop for wide encodings. reported by Ralf Junker a
[ruby-core:24892]. [ruby-core:24904]
Wed Aug 12 21:07:46 2009 NAKAMURA Usaku <usa@ruby-lang.org>
* ext/socket/extconf.rb: if ipv6 is enabled, the version of Windows

View file

@ -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);
}
}