From: K.Kosako Date: Sun, 21 Aug 2016 08:42:18 +0000 (+0900) Subject: fix out of bounds read in mbc_to_code() #16 X-Git-Tag: v6.1.0~44 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=65bdf2a0d160d06556415e5f396a75f6b11bad5c;p=onig fix out of bounds read in mbc_to_code() #16 --- diff --git a/src/utf8.c b/src/utf8.c index b78e7eb..f82bcc2 100644 --- a/src/utf8.c +++ b/src/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--) {