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



commit 74c20f2222538d5018c18c36e1eb7e502cd92d0b
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.
    (cherry picked from commit 7d280abd9a657ba3a649a8823aeaf9d877e8d21e)

 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]