[jruby-joni] 05/08: fix IOOBes for backref at level and multiplex definitions
Hideki Yamane
henrich at moszumanska.debian.org
Fri Dec 25 13:46:01 UTC 2015
This is an automated email from the git hooks/post-receive script.
henrich pushed a commit to branch debian/sid
in repository jruby-joni.
commit 2d4580d16ac757606591dbc6ed6475dfec85aea0
Author: Marcin Mielzynski <lopx at gazeta.pl>
Date: Mon Dec 14 22:47:16 2015 +0100
fix IOOBes for backref at level and multiplex definitions
---
src/org/joni/ByteCodeMachine.java | 9 ++++++---
test/org/joni/test/TestU8.java | 2 ++
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/org/joni/ByteCodeMachine.java b/src/org/joni/ByteCodeMachine.java
index 262ea71..5cf643e 100644
--- a/src/org/joni/ByteCodeMachine.java
+++ b/src/org/joni/ByteCodeMachine.java
@@ -1352,8 +1352,9 @@ class ByteCodeMachine extends StackMachine {
s = value;
int len;
- // if (sprev < bytes.length)
- while (sprev + (len = enc.length(bytes, sprev, end)) < s) sprev += len;
+ if (sprev < range) {
+ while (sprev + (len = enc.length(bytes, sprev, end)) < s) sprev += len;
+ }
ip += tlen - i - 1; // * SIZE_MEMNUM (1)
break; /* success */
@@ -1425,7 +1426,9 @@ class ByteCodeMachine extends StackMachine {
sprev = s;
if (backrefMatchAtNestedLevel(ic != 0, regex.caseFoldFlag, level, tlen, ip)) { // (s) and (end) implicit
int len;
- while (sprev + (len = enc.length(bytes, sprev, end)) < s) sprev += len;
+ if (sprev < range) {
+ while (sprev + (len = enc.length(bytes, sprev, end)) < s) sprev += len;
+ }
ip += tlen; // * SIZE_MEMNUM
} else {
{opFail(); return;}
diff --git a/test/org/joni/test/TestU8.java b/test/org/joni/test/TestU8.java
index 24f1dde..5881db4 100644
--- a/test/org/joni/test/TestU8.java
+++ b/test/org/joni/test/TestU8.java
@@ -93,6 +93,8 @@ public class TestU8 extends Test {
x2s("foo\\b", "foo", 0, 3);
x2s("(x?)x*\\1", "x", 0, 1, Option.IGNORECASE);
+ x2s("(x?)x*\\k<1+0>", "x", 0, 1, Option.IGNORECASE);
+ x2s("(?<n>x?)(?<n>x?)\\k<n>", "x", 0, 1, Option.IGNORECASE);
}
public static void main(String[] args) throws Throwable {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jruby-joni.git
More information about the pkg-java-commits
mailing list