diff --git a/src/org/joni/ByteCodeMachine.java b/src/org/joni/ByteCodeMachine.java index db4d6a2e..9056166e 100644 --- a/src/org/joni/ByteCodeMachine.java +++ b/src/org/joni/ByteCodeMachine.java @@ -526,7 +526,7 @@ private void opExactMB2N3() { private void opExactMB2N() { int tlen = code[ip++]; - if (tlen * 2 > range) {opFail(); return;} + if (s + tlen * 2 > range) {opFail(); return;} if (Config.USE_STRING_TEMPLATES) { byte[]bs = regex.templates[code[ip++]]; @@ -551,7 +551,7 @@ private void opExactMB2N() { private void opExactMB3N() { int tlen = code[ip++]; - if (tlen * 3 > range) {opFail(); return;} + if (s + tlen * 3 > range) {opFail(); return;} if (Config.USE_STRING_TEMPLATES) { byte[]bs = regex.templates[code[ip++]]; diff --git a/test/org/joni/test/TestU8.java b/test/org/joni/test/TestU8.java index a3f0767f..53400f69 100644 --- a/test/org/joni/test/TestU8.java +++ b/test/org/joni/test/TestU8.java @@ -75,6 +75,7 @@ public void test() { // x2s(pat2, str2, 4, 4); // x2s(pat2, str2, 4, 4, Option.IGNORECASE); + ns("(?i-mx:ak)a", "ema"); } public static void main(String[] args) throws Throwable {