8225292: Better Graphics2D drawing
authorprr
Sun, 16 Jun 2019 13:14:32 -0700
changeset 58633 0c518cbf1dcc
parent 58632 fbab568169c4
child 58634 da71aa13f86b
8225292: Better Graphics2D drawing Reviewed-by: serb, psadhukhan, mschoene, rhalade
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 */