< prev index next >

src/share/classes/java/util/regex/Pattern.java

Print this page
rev 12216 : imported patch 8169056-StringIndexOutOfBoundsException-in-Pattern-compile-with-CANON_EQ-flag

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -1409,10 +1409,12 @@
         StringBuilder eq = null;
         int lastCodePoint = -1;
         String result;
 
         i++;
+        if (i == normalizedPattern.length())
+            throw error("Unclosed character class");
         charClass.append("[");
         while(true) {
             int c = normalizedPattern.codePointAt(i);
             StringBuilder sequenceBuffer;
 
< prev index next >