diff -pur gimp-1.3-orig/app/display/gimpdisplayshell-selection.c gimp-1.3-mine/app/display/gimpdisplayshell-selection.c
--- gimp-1.3-orig/app/display/gimpdisplayshell-selection.c	Thu Mar 20 12:31:29 2003
+++ gimp-1.3-mine/app/display/gimpdisplayshell-selection.c	Fri Apr  4 23:25:46 2003
@@ -486,10 +486,14 @@ selection_render_points (Selection *sele
   gint dx, dy;
   gint dxa, dya;
   gint r;
+  gint xsize, ysize;
+  gint x2, y2;
 
   if (select->segs_in == NULL)
     return;
 
+  g_return_if_fail (select->shell != NULL);
+
   for (j = 0; j < 8; j++)
     {
       max_npoints[j] = MAX_POINTS_INC;
@@ -497,6 +501,9 @@ selection_render_points (Selection *sele
       select->num_points_in[j] = 0;
     }
 
+  xsize = select->shell->disp_width;
+  ysize = select->shell->disp_height;
+
   for (i = 0; i < select->num_segs_in; i++)
     {
 #ifdef VERBOSE
@@ -506,8 +513,9 @@ selection_render_points (Selection *sele
 	       select->segs_in[i].x2,
 	       select->segs_in[i].y2);
 #endif
-      x = select->segs_in[i].x1;
-      dxa = select->segs_in[i].x2 - x;
+      x = CLAMP (select->segs_in[i].x1, -1, xsize);
+      x2 = CLAMP (select->segs_in[i].x2, -1, xsize);
+      dxa = x2 - x;
       if (dxa > 0)
 	{
 	  dx = 1;
@@ -517,8 +525,9 @@ selection_render_points (Selection *sele
 	  dxa = -dxa;
 	  dx = -1;
 	}
-      y = select->segs_in[i].y1;
-      dya = select->segs_in[i].y2 - y;
+      y = CLAMP (select->segs_in[i].y1, -1, ysize);
+      y2 = CLAMP (select->segs_in[i].y2, -1, ysize);
+      dya = y2 - y;
       if (dya > 0)
 	{
 	  dy = 1;
@@ -542,7 +551,7 @@ selection_render_points (Selection *sele
 	      y += dy;
 	      r -= (dxa << 1);
 	    }
-	  } while (x != select->segs_in[i].x2);
+	  } while (x != x2);
 	}
       else if (dxa < dya)
 	{
@@ -558,7 +567,7 @@ selection_render_points (Selection *sele
 	      x += dx;
 	      r -= (dya << 1);
 	    }
-	  } while (y != select->segs_in[i].y2);
+	  } while (y != y2);
 	}
       else
 	selection_add_point (select->points_in,
@@ -724,9 +733,22 @@ selection_generate_segs (Selection *sele
 
   if (select->num_segs_layer)
     {
+      gint i;
+      GdkSegment *seg;
+
       select->segs_layer = g_new (GdkSegment, select->num_segs_layer);
       selection_transform_segs (select, segs_layer, select->segs_layer,
 				select->num_segs_layer);
+
+      seg = select->segs_layer;
+      for (i = 0; i < select->num_segs_layer; i++)
+        {
+          seg->x1 = CLAMP (seg->x1, -1, select->shell->disp_width);
+          seg->y1 = CLAMP (seg->y1, -1, select->shell->disp_height);
+          seg->x2 = CLAMP (seg->x2, -1, select->shell->disp_width);
+          seg->y2 = CLAMP (seg->y2, -1, select->shell->disp_height);
+          seg++;
+        }
     }
   else
     {
