2006-05-30  Sven de Marothy  <[EMAIL PROTECTED]>

        Should fix PR 27835
        * gnu/java/awt/peer/gtk/BufferedImageGraphics.java
        (updateBufferedImage): Keep within image bounds.


Index: gnu/java/awt/peer/gtk/BufferedImageGraphics.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/gtk/BufferedImageGraphics.java,v
retrieving revision 1.1
diff -U3 -r1.1 BufferedImageGraphics.java
--- gnu/java/awt/peer/gtk/BufferedImageGraphics.java	29 May 2006 16:14:59 -0000	1.1
+++ gnu/java/awt/peer/gtk/BufferedImageGraphics.java	31 May 2006 20:50:34 -0000
@@ -119,7 +119,16 @@
   private void updateBufferedImage(int x, int y, int width, int height)
   {
     int[] pixels = surface.getPixels(imageWidth * imageHeight * 4);
-
+    if( x > imageWidth || y > imageHeight )
+      return;
+    // Clip edges.
+    if( x < 0 ){ width = width + x; x = 0; }
+    if( y < 0 ){ height = height + y; y = 0; }
+    if( x + width > imageWidth ) 
+      width = imageWidth - x;
+    if( y + height > imageHeight ) 
+      height = imageHeight - y;
+    
     int index = 0;
     for (int j = y; j < y + height; ++j)
       for (int i = x; i < x + width; ++i)

Reply via email to