Index: plug-ins/common/gauss_iir.c
===================================================================
RCS file: /cvs/gnome/gimp/plug-ins/common/gauss_iir.c,v
retrieving revision 1.43
diff -u -p -r1.43 gauss_iir.c
--- plug-ins/common/gauss_iir.c	31 Oct 2002 21:38:01 -0000	1.43
+++ plug-ins/common/gauss_iir.c	17 Nov 2002 01:22:57 -0000
@@ -577,6 +577,7 @@ gauss_iir (GimpDrawable *drawable,
   guchar *guc_tmp1, *guc_tmp2;
   gint *gi_tmp1, *gi_tmp2;
   gdouble std_dev;
+  gint padx, pady, paddedx1, paddedy1;
 
   if (horz <= 0.0 && vert <= 0.0)
     return;
@@ -589,6 +590,19 @@ gauss_iir (GimpDrawable *drawable,
   if (width < 1 || height < 1)
     return;
 
+  /* Readjust, cos we are interested not only in destination pixels */
+  /* but in all source pixels that will affect the computation      */
+  padx = 200; /* What value? Hardcoding is not the way. */
+  pady = 200; /* Should be based in horz and vert       */
+  width  += (2 * padx);
+  height += (2 * pady);
+
+  /* But avoiding "underflow" or "overflow" */
+  paddedx1 = MAX(0, (x1 - padx));
+  paddedy1 = MAX(0, (y1 - pady));
+  width  = MIN((drawable->width - paddedx1), width);
+  height = MIN((drawable->height - paddedy1), height);
+
   bytes = drawable->bpp;
   has_alpha = gimp_drawable_has_alpha(drawable->drawable_id);
 
@@ -626,7 +640,7 @@ gauss_iir (GimpDrawable *drawable,
 	  memset(val_p, 0, height * bytes * sizeof (gdouble));
 	  memset(val_m, 0, height * bytes * sizeof (gdouble));
 
-	  gimp_pixel_rgn_get_col (&src_rgn, src, col + x1, y1, (y2 - y1));
+	  gimp_pixel_rgn_get_col (&src_rgn, src, (col + paddedx1), paddedy1, height);
 
 	  sp_p = src;
 	  sp_m = src + (height - 1) * bytes;
@@ -680,7 +694,7 @@ gauss_iir (GimpDrawable *drawable,
 
 	  transfer_pixels (val_p, val_m, dest, bytes, height);
 
-	  gimp_pixel_rgn_set_col (&dest_rgn, dest, col + x1, y1, (y2 - y1));
+	  gimp_pixel_rgn_set_col (&dest_rgn, dest, (col + paddedx1), paddedy1, height);
 
 	  progress += height * vert;
 	  if ((col % 5) == 0)
@@ -711,7 +725,7 @@ if (horz > 0.0)
 	  memset(val_p, 0, width * bytes * sizeof (gdouble));
 	  memset(val_m, 0, width * bytes * sizeof (gdouble));
 
-	  gimp_pixel_rgn_get_row (&src_rgn, src, x1, row + y1, (x2 - x1));
+	  gimp_pixel_rgn_get_row (&src_rgn, src, paddedx1, (row + paddedy1), width);
 
 	  sp_p = src;
 	  sp_m = src + (width - 1) * bytes;
@@ -765,7 +779,7 @@ if (horz > 0.0)
 
 	  transfer_pixels (val_p, val_m, dest, bytes, width);
 
-	  gimp_pixel_rgn_set_row (&dest_rgn, dest, x1, row + y1, (x2 - x1));
+	  gimp_pixel_rgn_set_row (&dest_rgn, dest, paddedx1, (row + paddedy1), width);
 
 	  progress += width * horz;
 	  if ((row % 5) == 0)
@@ -779,7 +793,7 @@ if (horz > 0.0)
   /*  merge the shadow, update the drawable  */
   gimp_drawable_flush (drawable);
   gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
-  gimp_drawable_update (drawable->drawable_id, x1, y1, (x2 - x1), (y2 - y1));
+  gimp_drawable_update (drawable->drawable_id, paddedx1, paddedy1, width, height);
 
   /*  free up buffers  */
   g_free (val_p);
