From 8cfbc003fecfea3ce33c685fd7f21f70709fdd5b Mon Sep 17 00:00:00 2001 From: igerasim Date: Wed, 22 May 2019 19:41:59 -0700 Subject: [PATCH] 8222684: Better support for patterns 8223163: Better pattern recognition Reviewed-by: ahgross, bchristi, jeff, rhalade, rriggs, smarks --- src/share/classes/java/util/regex/Pattern.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/share/classes/java/util/regex/Pattern.java b/src/share/classes/java/util/regex/Pattern.java index 009a46e6f..743439012 100644 --- a/src/share/classes/java/util/regex/Pattern.java +++ b/src/share/classes/java/util/regex/Pattern.java @@ -1348,7 +1348,11 @@ public final class Pattern localCount = 0; if (pattern.length() > 0) { - compile(); + try { + compile(); + } catch (StackOverflowError soe) { + throw error("Stack overflow during pattern compilation"); + } } else { root = new Start(lastAccept); matchRoot = lastAccept; @@ -1905,6 +1909,10 @@ loop: for(int x=0, offset=0; x patternLength) { + cursor = patternLength; + ch = temp[cursor++]; + } return ch; } @@ -1915,6 +1923,10 @@ loop: for(int x=0, offset=0; x patternLength) { + cursor = patternLength; + ch = temp[cursor]; + } return ch; } -- GitLab