From 5940c98c66ce84dd5ae00d9e9c4d394f1d96cf85 Mon Sep 17 00:00:00 2001 From: bae Date: Fri, 15 Oct 2010 11:26:43 +0400 Subject: [PATCH] 6773022: java.awt.image.SampleModel.getDataElements() does't throw ArrayIndexOutOfBoundsEx for Integer.MAX_V Reviewed-by: igor, prr --- .../classes/java/awt/image/SampleModel.java | 29 ++++++--- test/java/awt/image/GetDataElementsTest.java | 62 +++++++++++++++++++ 2 files changed, 81 insertions(+), 10 deletions(-) create mode 100644 test/java/awt/image/GetDataElementsTest.java diff --git a/src/share/classes/java/awt/image/SampleModel.java b/src/share/classes/java/awt/image/SampleModel.java index a2b02c44a..0bdb6a5ba 100644 --- a/src/share/classes/java/awt/image/SampleModel.java +++ b/src/share/classes/java/awt/image/SampleModel.java @@ -358,6 +358,15 @@ public abstract class SampleModel int cnt = 0; Object o = null; + int x1 = x + w; + int y1 = y + h; + + if (x < 0 || x1 < x || x1 > width || + y < 0 || y1 < y || y1 > height) + { + throw new ArrayIndexOutOfBoundsException("Invalid coordinates."); + } + switch(type) { case DataBuffer.TYPE_BYTE: @@ -370,8 +379,8 @@ public abstract class SampleModel else bdata = (byte[])obj; - for (int i=y; i