diff options
author | Jon Trowbridge <trow@ximian.com> | 2001-05-15 04:57:35 +0800 |
---|---|---|
committer | Jon Trowbridge <trow@src.gnome.org> | 2001-05-15 04:57:35 +0800 |
commit | b63edae65e589775b1169e9111755f00b09bd610 (patch) | |
tree | a7044b01bd5cadb84a74e4fced4a7a884d1bc699 /widgets/text/e-text.c | |
parent | d538a34c4bbc028828dac7c147eace3cd8e2a0e2 (diff) | |
download | gsoc2013-evolution-b63edae65e589775b1169e9111755f00b09bd610.tar.gz gsoc2013-evolution-b63edae65e589775b1169e9111755f00b09bd610.tar.zst gsoc2013-evolution-b63edae65e589775b1169e9111755f00b09bd610.zip |
Validate utf8 to avoid lock-ups. (_get_position): Validate utf8 to avoid
2001-05-14 Jon Trowbridge <trow@ximian.com>
* gal/e-text/e-text.c (calc_line_widths): Validate utf8 to avoid
lock-ups.
(_get_position): Validate utf8 to avoid lock-ups.
svn path=/trunk/; revision=9797
Diffstat (limited to 'widgets/text/e-text.c')
-rw-r--r-- | widgets/text/e-text.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/widgets/text/e-text.c b/widgets/text/e-text.c index 0638134281..b2eb2ad3b0 100644 --- a/widgets/text/e-text.c +++ b/widgets/text/e-text.c @@ -807,7 +807,9 @@ calc_line_widths (EText *text) clip_width >= 0) { if (text->font) { lines->ellipsis_length = 0; - for (p = lines->text; p && *p && (p - lines->text) < lines->length; p = g_utf8_next_char (p)) { + for (p = lines->text; + p && *p && g_unichar_validate (g_utf8_get_char (p)) && (p - lines->text) < lines->length; + p = g_utf8_next_char (p)) { gint text_width = text_width_with_objects (text->model, text->font, text->style, lines->text, p - lines->text); @@ -3206,7 +3208,7 @@ _get_position(EText *text, ETextEventProcessorCommand *command) p = g_utf8_next_char (text->text + text->selection_end); - while (p && *p) { + while (p && *p && g_unichar_validate (g_utf8_get_char (p))) { if (*p == '\n') { new_pos = p - text->text; p = NULL; @@ -3253,7 +3255,7 @@ _get_position(EText *text, ETextEventProcessorCommand *command) p = g_utf8_next_char (text->text + text->selection_end); - while (p && *p) { + while (p && *p && g_unichar_validate (g_utf8_get_char (p))) { unival = g_utf8_get_char (p); if (g_unichar_isspace (unival)) { new_pos = p - text->text; @@ -3275,7 +3277,7 @@ _get_position(EText *text, ETextEventProcessorCommand *command) if (p != text->text) { p = g_utf8_find_prev_char (text->text, p); - while (p && p > text->text) { + while (p && p > text->text && g_unichar_validate (g_utf8_get_char (p))) { unival = g_utf8_get_char (p); if (g_unichar_isspace (unival)) { new_pos = g_utf8_next_char (p) - text->text; @@ -3328,7 +3330,7 @@ _get_position(EText *text, ETextEventProcessorCommand *command) } p = g_utf8_find_prev_char (text->text, p); - while (p && p > text->text) { + while (p && p > text->text && g_unichar_validate (g_utf8_get_char (p))) { unival = g_utf8_get_char (p); if (g_unichar_isspace (unival)) { p = g_utf8_next_char (p); @@ -3353,7 +3355,7 @@ _get_position(EText *text, ETextEventProcessorCommand *command) p = g_utf8_next_char (text->text + text->selection_end); - while (p && *p) { + while (p && *p && g_unichar_validate (g_utf8_get_char (p))) { unival = g_utf8_get_char (p); if (g_unichar_isspace (unival)) { new_pos = p - text->text; |