Backported from 5.6.26 by Remi. From 486056b2153f7177cd8a7c78d93968726ee8fa65 Mon Sep 17 00:00:00 2001 From: Stanislav Malyshev Date: Thu, 1 Sep 2016 23:27:06 -0700 Subject: [PATCH] Fix bug #72910 Merge upstream patch from https://github.com/kkos/oniguruma/commit/65bdf2a0d160d06556415e5f396a75f6b11bad5c --- ext/mbstring/oniguruma/enc/utf8.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/mbstring/oniguruma/enc/utf8.c b/ext/mbstring/oniguruma/enc/utf8.c index 5e2c172..74122e1 100644 --- a/ext/mbstring/oniguruma/enc/utf8.c +++ b/ext/mbstring/oniguruma/enc/utf8.c @@ -98,7 +98,7 @@ mbc_to_code(const UChar* p, const UChar* end ARG_UNUSED) len = enclen(ONIG_ENCODING_UTF8, p); c = *p++; - if (len > 1) { + if (len > 1 && p < end) { len--; n = c & ((1 << (6 - len)) - 1); while (len--) { From b570c506815212c7702bfb0046e87d541e171eb7 Mon Sep 17 00:00:00 2001 From: Stanislav Malyshev Date: Sun, 4 Sep 2016 19:13:22 -0700 Subject: [PATCH] Sync fix for bug #72910 with current upstream --- ext/mbstring/oniguruma/enc/utf8.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ext/mbstring/oniguruma/enc/utf8.c b/ext/mbstring/oniguruma/enc/utf8.c index 74122e1..9e8478f 100644 --- a/ext/mbstring/oniguruma/enc/utf8.c +++ b/ext/mbstring/oniguruma/enc/utf8.c @@ -91,14 +91,16 @@ is_mbc_newline(const UChar* p, const UChar* end) } static OnigCodePoint -mbc_to_code(const UChar* p, const UChar* end ARG_UNUSED) +mbc_to_code(const UChar* p, const UChar* end) { int c, len; OnigCodePoint n; - len = enclen(ONIG_ENCODING_UTF8, p); + len = mbc_enc_len(p); + if (len > end - p) len = end - p; + c = *p++; - if (len > 1 && p < end) { + if (len > 1) { len--; n = c & ((1 << (6 - len)) - 1); while (len--) {