Index: glib/gutf8.c
===================================================================
RCS file: /cvs/gnome/glib/glib/gutf8.c,v
retrieving revision 1.45
diff -u -p -r1.45 gutf8.c
--- glib/gutf8.c	30 Oct 2005 03:05:21 -0000	1.45
+++ glib/gutf8.c	8 Nov 2005 20:52:57 -0000
@@ -291,9 +291,19 @@ g_utf8_offset_to_pointer  (const gchar *
 			   glong        offset)    
 {
   const gchar *s = str;
-  while (offset--)
-    s = g_utf8_next_char (s);
-  
+  if (offset > 0) 
+    while (offset--)
+      s = g_utf8_next_char (s);
+  else
+    while (offset)
+      {
+	s += offset;
+	while ((*s & 0xc0) == 0x80)
+          s--;
+
+	offset += g_utf8_pointer_to_offset (s, str);
+      }
+
   return (gchar *)s;
 }
 
Index: gtk/gtktextiter.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktextiter.c,v
retrieving revision 1.88
diff -u -p -r1.88 gtktextiter.c
--- gtk/gtktextiter.c	2 Nov 2005 05:08:31 -0000	1.88
+++ gtk/gtktextiter.c	8 Nov 2005 20:53:32 -0000
@@ -2391,14 +2391,17 @@ gtk_text_iter_backward_chars (GtkTextIte
 
       if (real->line_byte_offset >= 0)
         {
-          const char *p;
           gint new_byte_offset;
-          gint i;
+          const char * end;
 
-          p = g_utf8_offset_to_pointer (real->segment->body.chars,
-                                        real->segment_char_offset);
+          if (count < real->segment_char_offset) 
+            end = g_utf8_offset_to_pointer (real->segment->body.chars + real->segment_byte_offset, 
+					    -count);
+          else
+            end = g_utf8_offset_to_pointer (real->segment->body.chars,
+                                            real->segment_char_offset);
 
-          new_byte_offset = p - real->segment->body.chars;
+          new_byte_offset = end - real->segment->body.chars;
           real->line_byte_offset -= (real->segment_byte_offset - new_byte_offset);
           real->segment_byte_offset = new_byte_offset;
         }
