8340554: Improve MessageFormat readObject checks
Reviewed-by: naoto
This commit is contained in:
parent
7d5eefa506
commit
7af46a6b42
src/java.base/share/classes/java/text
test/jdk/java/text/Format/MessageFormat
@ -2041,7 +2041,7 @@ public class MessageFormat extends Format {
|
|||||||
|
|
||||||
// Check the correctness of arguments and offsets
|
// Check the correctness of arguments and offsets
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
int lastOffset = patt.length() + 1;
|
int lastOffset = patt.length();
|
||||||
for (int i = maxOff; i >= 0; --i) {
|
for (int i = maxOff; i >= 0; --i) {
|
||||||
if (argNums[i] < 0 || argNums[i] >= MAX_ARGUMENT_INDEX
|
if (argNums[i] < 0 || argNums[i] >= MAX_ARGUMENT_INDEX
|
||||||
|| offs[i] < 0 || offs[i] > lastOffset) {
|
|| offs[i] < 0 || offs[i] > lastOffset) {
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8331446
|
* @bug 8331446 8340554
|
||||||
* @summary Check correctness of deserialization
|
* @summary Check correctness of deserialization
|
||||||
* @run junit SerializationTest
|
* @run junit SerializationTest
|
||||||
*/
|
*/
|
||||||
@ -70,7 +70,13 @@ public class SerializationTest {
|
|||||||
// With null locale. (NPE not thrown, if no format defined)
|
// With null locale. (NPE not thrown, if no format defined)
|
||||||
new MessageFormat("{1} {0} foo", null),
|
new MessageFormat("{1} {0} foo", null),
|
||||||
// With formats
|
// With formats
|
||||||
new MessageFormat("{0,number,short} {0} {1,date,long} foo")
|
new MessageFormat("{0,number,short} {0} {1,date,long} foo"),
|
||||||
|
// Offset equal to pattern length (0)
|
||||||
|
new MessageFormat("{0}"),
|
||||||
|
// Offset equal to pattern length (1)
|
||||||
|
new MessageFormat("X{0}"),
|
||||||
|
// Offset 1 under pattern length
|
||||||
|
new MessageFormat("X{0}X")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user