[gimp/metadata-browser] Bug 676585 - Gimp crashes when writing in Arabic and clicking right arrow



commit 210d537adce93c3e25eb47e12acc91ce05b53f5d
Author: Michael Natterer <mitch gimp org>
Date:   Wed May 23 09:44:51 2012 +0200

    Bug 676585 - Gimp crashes when writing in Arabic and clicking right arrow
    
    Check for pango_layout_move_cursor_visually() returning a new index of
    G_MAXINT, which indicates that we moved beyond the end of the layout,
    and do nothing instead of trying to access the memory there.

 app/tools/gimptexttool-editor.c |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/app/tools/gimptexttool-editor.c b/app/tools/gimptexttool-editor.c
index bb15762..37c4c5f 100644
--- a/app/tools/gimptexttool-editor.c
+++ b/app/tools/gimptexttool-editor.c
@@ -698,23 +698,31 @@ gimp_text_tool_move_cursor (GimpTextTool    *text_tool,
               if (count > 0)
                 {
                   if (g_utf8_get_char (text + index) == word_joiner)
-                    pango_layout_move_cursor_visually (layout, TRUE, index, 0, 1,
+                    pango_layout_move_cursor_visually (layout, TRUE,
+                                                       index, 0, 1,
                                                        &new_index, &trailing);
                   else
                     new_index = index;
 
-                  pango_layout_move_cursor_visually (layout, TRUE, new_index, trailing, 1,
+                  pango_layout_move_cursor_visually (layout, TRUE,
+                                                     new_index, trailing, 1,
                                                      &new_index, &trailing);
                   count--;
                 }
               else
                 {
-                  pango_layout_move_cursor_visually (layout, TRUE, index, 0, -1,
+                  pango_layout_move_cursor_visually (layout, TRUE,
+                                                     index, 0, -1,
                                                      &new_index, &trailing);
 
-                  if (new_index != -1 && g_utf8_get_char (text + new_index) == word_joiner)
-                    pango_layout_move_cursor_visually (layout, TRUE, new_index, trailing, -1,
-                                                       &new_index, &trailing);
+                  if (new_index != -1 && new_index != G_MAXINT &&
+                      g_utf8_get_char (text + new_index) == word_joiner)
+                    {
+                      pango_layout_move_cursor_visually (layout, TRUE,
+                                                         new_index, trailing, -1,
+                                                         &new_index, &trailing);
+                    }
+
                   count++;
                 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]