From 945c600a6d31b5022bfcd8917bdd2fb5e0327d5b Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 27 Mar 2017 18:12:18 +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_3@58188 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 c9583a3288..c2595cbba9 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