Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 66950 invoked from network); 11 Jan 2007 17:54:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Jan 2007 17:54:11 -0000 Received: (qmail 75385 invoked by uid 500); 11 Jan 2007 17:54:18 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 75353 invoked by uid 500); 11 Jan 2007 17:54:18 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 75338 invoked by uid 99); 11 Jan 2007 17:54:18 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Jan 2007 09:54:18 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Jan 2007 09:54:10 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id CFAD51A981D; Thu, 11 Jan 2007 09:53:09 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r495310 - in /harmony/enhanced/classlib/trunk/modules/awt/src: main/java/common/java/awt/image/ComponentSampleModel.java test/api/java/common/java/awt/image/ComponentSampleModelTest.java Date: Thu, 11 Jan 2007 17:53:09 -0000 To: commits@harmony.apache.org From: ayza@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070111175309.CFAD51A981D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ayza Date: Thu Jan 11 09:53:08 2007 New Revision: 495310 URL: http://svn.apache.org/viewvc?view=rev&rev=495310 Log: Applying patch from HARMONY-2783 ([classlib][awt] Compatibility: java.awt.image.ComponentSampleModel.getPixels(int,int,inrt,int,int[],DataBuffer) does not throw ArrayIndexOutOfBoundsException while RI throws it) Added: harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/ComponentSampleModelTest.java Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/ComponentSampleModel.java Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/ComponentSampleModel.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/ComponentSampleModel.java?view=diff&rev=495310&r1=495309&r2=495310 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/ComponentSampleModel.java (original) +++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/ComponentSampleModel.java Thu Jan 11 09:53:08 2007 @@ -331,7 +331,8 @@ @Override public int[] getPixels(int x, int y, int w, int h, int iArray[], DataBuffer data) { - if (x < 0 || y < 0 || x + w > this.width || y + h > this.height) { + if (x < 0 || y < 0 || x > this.width || x + w > this.width + || y > this.height || y + h > this.height) { // awt.63=Coordinates are not in bounds throw new ArrayIndexOutOfBoundsException(Messages.getString("awt.63")); //$NON-NLS-1$ } @@ -571,4 +572,5 @@ } } + Added: harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/ComponentSampleModelTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/ComponentSampleModelTest.java?view=auto&rev=495310 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/ComponentSampleModelTest.java (added) +++ harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/ComponentSampleModelTest.java Thu Jan 11 09:53:08 2007 @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package java.awt.image; + +import junit.framework.TestCase; + +public class ComponentSampleModelTest extends TestCase { + + public void testGetPixelsMaxValue() throws Exception { + ComponentSampleModel csm = new ComponentSampleModel(0, 10, 10, 1, 10, new int[]{0}); + DataBufferInt dbi = new DataBufferInt(100); + + try { + csm.getPixels(8, Integer.MAX_VALUE, 1, 1, (int[]) null, dbi); + fail("Exception expected"); + } catch(ArrayIndexOutOfBoundsException expectedException) { + // expected + } + } +}