harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r496048 - in /harmony/enhanced/classlib/trunk/modules/awt/src: main/java/common/java/awt/image/RescaleOp.java test/api/java/common/java/awt/image/RescaleOpTest.java
Date Sun, 14 Jan 2007 09:36:03 GMT
Author: hindessm
Date: Sun Jan 14 01:36:03 2007
New Revision: 496048

URL: http://svn.apache.org/viewvc?view=rev&rev=496048
Log:
Applying patches from "[#HARMONY-2689] [classlib][awt]
java.awt.image.RescaleOp.getOffsets() throws unexpected IAE if an array has
zero legth size.".

Added:
    harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/RescaleOpTest.java
  (with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/RescaleOp.java

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/RescaleOp.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/RescaleOp.java?view=diff&rev=496048&r1=496047&r2=496048
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/RescaleOp.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/RescaleOp.java
Sun Jan 14 01:36:03 2007
@@ -82,7 +82,8 @@
             scaleFactors = new float[this.scaleFactors.length];
         }
 
-        System.arraycopy(this.scaleFactors, 0, scaleFactors, 0, this.scaleFactors.length);
+        int minLength = Math.min(scaleFactors.length, this.scaleFactors.length);
+        System.arraycopy(this.scaleFactors, 0, scaleFactors, 0, minLength);
         return scaleFactors;
     }
 
@@ -91,7 +92,8 @@
             offsets = new float[this.offsets.length];
         }
 
-        System.arraycopy(this.offsets, 0, offsets, 0, this.offsets.length);
+        int minLength = Math.min(offsets.length, this.offsets.length);
+        System.arraycopy(this.offsets, 0, offsets, 0, minLength);
         return offsets;
     }
 

Added: harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/RescaleOpTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/RescaleOpTest.java?view=auto&rev=496048
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/RescaleOpTest.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/RescaleOpTest.java
Sun Jan 14 01:36:03 2007
@@ -0,0 +1,37 @@
+/*
+ *  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 RescaleOpTest extends TestCase {
+    // A regression test for harmony-2689
+    public void test_getOffsetsNullLength()
+    {
+        RescaleOp res = new RescaleOp(new float[1],new float[2],null);
+        assertEquals(res.getOffsets(new float[] {}).length, 0);
+    }
+    
+    // A regression test for harmony-2689
+    public void test_getScaleFactorsNullLength()
+    {
+        RescaleOp res = new RescaleOp(new float[1],new float[2],null);
+        assertEquals(res.getScaleFactors(new float[] {}).length, 0);
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/RescaleOpTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message