diff --git a/src/share/classes/sun/java2d/SunGraphics2D.java b/src/share/classes/sun/java2d/SunGraphics2D.java index 0ad5e1655b8baee02b5891b3bbcc07c4024583ec..ca19a1dce54c23a9873dd75a77080993d9dc0a5d 100644 --- a/src/share/classes/sun/java2d/SunGraphics2D.java +++ b/src/share/classes/sun/java2d/SunGraphics2D.java @@ -3020,7 +3020,8 @@ public final class SunGraphics2D 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()) { @@ -3052,7 +3053,8 @@ public final class SunGraphics2D 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 */