Bug 547303 – pango_layout_get_cursor_pos crashes on certain text buffers
authorBehdad Esfahbod <behdad@gnome.org>
Mon, 11 Aug 2008 18:17:23 +0000 (18:17 +0000)
committerBehdad Esfahbod <behdad@src.gnome.org>
Mon, 11 Aug 2008 18:17:23 +0000 (18:17 +0000)
2008-08-11  Behdad Esfahbod  <behdad@gnome.org>

        Bug 547303 – pango_layout_get_cursor_pos crashes on certain text
        buffers

        * pango/pango-layout.c (pango_layout_get_cursor_pos): Handle cursor
        position in the middle of a "\r\n" cluster.

svn path=/trunk/; revision=2688

ChangeLog
pango/pango-layout.c

index c7e2c68..0fd2249 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-08-11  Behdad Esfahbod  <behdad@gnome.org>
+
+       Bug 547303 – pango_layout_get_cursor_pos crashes on certain text
+       buffers
+
+       * pango/pango-layout.c (pango_layout_get_cursor_pos): Handle cursor
+       position in the middle of a "\r\n" cluster.
+
 2008-08-06  Behdad Esfahbod  <behdad@gnome.org>
 
        * pango/pangocairo-render.c (pango_cairo_renderer_draw_glyph_item):
index 1df4b03..262b403 100644 (file)
@@ -2194,6 +2194,14 @@ pango_layout_get_cursor_pos (PangoLayout    *layout,
       else
        x1_trailing = line_rect.width;
     }
+  else if (index >= layout_line->start_index + layout_line->length)
+    {
+      dir1 = layout_line->resolved_dir;
+      if (layout_line->resolved_dir == PANGO_DIRECTION_LTR)
+       x1_trailing = line_rect.width;
+      else
+       x1_trailing = 0;
+    }
   else
     {
       gint prev_index = g_utf8_prev_char (layout->text + index) - layout->text;