Index: gtk/gtktextdisplay.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktextdisplay.c,v
retrieving revision 1.39
diff -u -b -B -p -r1.39 gtktextdisplay.c
--- gtk/gtktextdisplay.c	10 Oct 2002 21:45:40 -0000	1.39
+++ gtk/gtktextdisplay.c	25 Dec 2002 00:13:22 -0000
@@ -803,6 +803,7 @@ gtk_text_layout_draw (GtkTextLayout *lay
                                                 &line_start,
                                                 line, 0);
               line_end = line_start;
+	      if (!gtk_text_iter_ends_line (&line_end))
               gtk_text_iter_forward_to_line_end (&line_end);
               byte_count = gtk_text_iter_get_line_index (&line_end);     
 
@@ -817,7 +818,7 @@ gtk_text_layout_draw (GtkTextLayout *lay
                   if (gtk_text_iter_compare (&selection_end, &line_end) <= 0)
                     selection_end_index = gtk_text_iter_get_line_index (&selection_end);
                   else
-                    selection_end_index = byte_count;
+                    selection_end_index = MAX(byte_count, 1);
                 }
             }
 
