From 55e32c2fbf627253650013b051dc4c81bb7cef11 Mon Sep 17 00:00:00 2001 From: prr Date: Sun, 16 Jun 2019 13:14:32 -0700 Subject: [PATCH] 8225292: Better Graphics2D drawing Reviewed-by: serb, psadhukhan, mschoene, rhalade --- src/share/classes/sun/java2d/SunGraphics2D.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/share/classes/sun/java2d/SunGraphics2D.java b/src/share/classes/sun/java2d/SunGraphics2D.java index 0ad5e1655..ca19a1dce 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 */ -- GitLab