8280403: RegEx: String.split can fail with NPE in Pattern.CharPredicate::match
Reviewed-by: lancea, iris, naoto, rriggs
This commit is contained in:
parent
52ddbe2dcd
commit
e3076552ec
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2022, 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
|
||||
@ -2689,6 +2689,8 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
|
||||
else
|
||||
prev = right;
|
||||
} else {
|
||||
if (curr == null)
|
||||
throw error("Bad intersection syntax");
|
||||
prev = prev.and(curr);
|
||||
}
|
||||
} else {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2022, 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
|
||||
@ -4547,4 +4547,13 @@ public class RegExTest {
|
||||
Pattern.compile(pattern));
|
||||
assertTrue(e.getMessage().contains("Unescaped trailing backslash"));
|
||||
}
|
||||
|
||||
//This test is for 8280403
|
||||
@Test
|
||||
public static void badIntersectionSyntax() {
|
||||
String pattern = "[˜\\H +F&&]";
|
||||
var e = expectThrows(PatternSyntaxException.class, () ->
|
||||
Pattern.compile(pattern));
|
||||
assertTrue(e.getMessage().contains("Bad intersection syntax"));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user