From b824ac5f129be6bdc53b500323e8bc1ca754f999 Mon Sep 17 00:00:00 2001 From: usa Date: Sat, 25 Mar 2017 16:58:03 +0000 Subject: * regcomp.c (set_bm_skip): Need to check the end of the string. this patch is from https://github.com/k-takata/Onigmo/commit/e5c0e6c36187898bb27960cd66d591f172558848 . [Backport #12997] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@58102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- regcomp.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'regcomp.c') diff --git a/regcomp.c b/regcomp.c index 6d002d3f44..d19366d22e 100644 --- a/regcomp.c +++ b/regcomp.c @@ -4192,6 +4192,8 @@ set_bm_skip(UChar* s, UChar* end, regex_t* reg, n = ONIGENC_GET_CASE_FOLD_CODES_BY_STR(enc, reg->case_fold_flag, p, end, items); clen = enclen(enc, p, end); + if (p + clen > end) + clen = (int )(end - p); for (j = 0; j < n; j++) { if ((items[j].code_len != 1) || (items[j].byte_len != clen)) @@ -4222,6 +4224,8 @@ set_bm_skip(UChar* s, UChar* end, regex_t* reg, n = ONIGENC_GET_CASE_FOLD_CODES_BY_STR(enc, reg->case_fold_flag, p, end, items); clen = enclen(enc, p, end); + if (p + clen > end) + clen = (int )(end - p); for (j = 0; j < n; j++) { if ((items[j].code_len != 1) || (items[j].byte_len != clen)) @@ -4265,6 +4269,8 @@ set_bm_skip(UChar* s, UChar* end, regex_t* reg, n = ONIGENC_GET_CASE_FOLD_CODES_BY_STR(enc, reg->case_fold_flag, p, end, items); clen = enclen(enc, p, end); + if (p + clen > end) + clen = (int )(end - p); for (j = 0; j < n; j++) { if ((items[j].code_len != 1) || (items[j].byte_len != clen)) @@ -4295,6 +4301,8 @@ set_bm_skip(UChar* s, UChar* end, regex_t* reg, n = ONIGENC_GET_CASE_FOLD_CODES_BY_STR(enc, reg->case_fold_flag, p, end, items); clen = enclen(enc, p, end); + if (p + clen > end) + clen = (int )(end - p); for (j = 0; j < n; j++) { if ((items[j].code_len != 1) || (items[j].byte_len != clen)) -- cgit v1.2.3