1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Index: ext/mbstring/libmbfl/mbfl/mbfilter.c
===================================================================
--- ext/mbstring/libmbfl/mbfl/mbfilter.c  (revision 305004)
+++ ext/mbstring/libmbfl/mbfl/mbfilter.c  (working copy)
@@ -1398,6 +1398,11 @@
       end   = start + (length & -4);
     } else if ((encoding->flag & MBFL_ENCTYPE_SBCS)) {
       start = string->val + from;
+
+      if (from + length >= string->len) {
+        length = string->len - from;
+      }
+
       end = start + length;
     } else if (encoding->mblen_table != NULL) {
       const unsigned char *mbtab = encoding->mblen_table;