# HG changeset patch # User prr # Date 1560716072 25200 # Node ID 0c518cbf1dcc148f9a630c12c9aa7f820a10f797 # Parent fbab568169c4cec9cf79b81e893a58a49cab1792 8225292: Better Graphics2D drawing Reviewed-by: serb, psadhukhan, mschoene, rhalade diff -r fbab568169c4 -r 0c518cbf1dcc src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java --- a/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java Fri Jun 14 20:33:17 2019 -0700 +++ b/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java Sun Jun 16 13:14:32 2019 -0700 @@ -3021,7 +3021,8 @@ if (data == null) { throw new NullPointerException("char data is null"); } - if (offset < 0 || length < 0 || offset + length > data.length) { + if (offset < 0 || length < 0 || offset + length < length || + offset + length > data.length) { throw new ArrayIndexOutOfBoundsException("bad offset/length"); } if (font.hasLayoutAttributes()) { @@ -3053,7 +3054,8 @@ if (data == null) { throw new NullPointerException("byte data is null"); } - if (offset < 0 || length < 0 || offset + length > data.length) { + if (offset < 0 || length < 0 || offset + length < length || + offset + length > data.length) { throw new ArrayIndexOutOfBoundsException("bad offset/length"); } /* Byte data is interpreted as 8-bit ASCII. Re-use drawChars loops */