Hi,
The following patch adds checks in Raster.createChild() and
WritableRaster.createWritableChild() to throw an appropriate exception
if the child's bounds extends beyond the parent's.
Corresponding Mauve tests have also been committed.
Cheers,
Francis
2006-10-17 Francis Kung <[EMAIL PROTECTED]>
* gnu/java/awt/peer/gtk/BufferedImageGraphics.java (drawComposite):
Ensure
composite does not extend beyond buffer bounds.
* java/awt/image/Raster.java (createChild): Ensure child does not
extend
beyond parent's bounds.
* java/awt/image/WritableRaster.java (createWritableChild): Ensure
child
does not extend beyond parent's bounds.
Index: gnu/java/awt/peer/gtk/BufferedImageGraphics.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/BufferedImageGraphics.java,v
retrieving revision 1.12
diff -u -r1.12 BufferedImageGraphics.java
--- gnu/java/awt/peer/gtk/BufferedImageGraphics.java 11 Oct 2006 20:14:59 -0000 1.12
+++ gnu/java/awt/peer/gtk/BufferedImageGraphics.java 17 Oct 2006 14:49:09 -0000
@@ -378,6 +378,9 @@
// Clip source to visible areas that need updating
Rectangle2D clip = this.getClipBounds();
Rectangle2D.intersect(bounds, clip, bounds);
+ clip = new Rectangle(buffer.getMinX(), buffer.getMinY(),
+ buffer.getWidth(), buffer.getHeight());
+ Rectangle2D.intersect(bounds, clip, bounds);
BufferedImage buffer2 = buffer;
if (!bounds.equals(buffer2.getRaster().getBounds()))
Index: java/awt/image/WritableRaster.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/awt/image/WritableRaster.java,v
retrieving revision 1.8
diff -u -r1.8 WritableRaster.java
--- java/awt/image/WritableRaster.java 18 Jul 2006 03:23:54 -0000 1.8
+++ java/awt/image/WritableRaster.java 17 Oct 2006 14:49:09 -0000
@@ -136,8 +136,9 @@
{
// This mirrors the code from the super class
- // FIXME: Throw RasterFormatException if child bounds extends
- // beyond the bounds of this raster.
+ if (parentX < minX || parentX + w > minX + width
+ || parentY < minY || parentY + h > minY + height)
+ throw new RasterFormatException("Child raster extends beyond parent");
SampleModel sm = (bandList == null) ?
sampleModel :
Index: java/awt/image/Raster.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/awt/image/Raster.java,v
retrieving revision 1.11
diff -u -r1.11 Raster.java
--- java/awt/image/Raster.java 18 Jul 2006 02:49:23 -0000 1.11
+++ java/awt/image/Raster.java 17 Oct 2006 14:49:09 -0000
@@ -511,9 +511,10 @@
int height, int childMinX, int childMinY,
int[] bandList)
{
- /* FIXME: Throw RasterFormatException if child bounds extends
- beyond the bounds of this raster. */
-
+ if (parentX < minX || parentX + width > minX + this.width
+ || parentY < minY || parentY + height > minY + this.height)
+ throw new RasterFormatException("Child raster extends beyond parent");
+
SampleModel sm = (bandList == null) ?
sampleModel :
sampleModel.createSubsetSampleModel(bandList);