diff --git a/ChangeLog b/ChangeLog index baca9a512..a0a067528 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,8 @@ WeeChat - Wee Enhanced Environment for Chat ChangeLog - 2006-05-14 Version 0.1.9 (under dev!): + * fixed crash with malformed UTF-8 strings + * fixed crash with ncurses color when too many colors defined in ncurses * added new key to find previous completion (shift-tab by default) * fixed bug with long outgoing IRC messages (> 512 bytes) (bug #16358) * fixed Ruby crash when handler does not return OK or KO (bug #16552) diff --git a/src/common/utf8.c b/src/common/utf8.c index 633aba411..11aa60808 100644 --- a/src/common/utf8.c +++ b/src/common/utf8.c @@ -65,7 +65,7 @@ utf8_init () int utf8_is_valid (char *string) { - while (string[0]) + while (string && string[0]) { /* UTF-8, 2 bytes, should be: 110vvvvv 10vvvvvv */ if (((unsigned char)(string[0]) & 0xE0) == 0xC0) @@ -219,7 +219,7 @@ utf8_strlen (char *string) return strlen (string); length = 0; - while (string[0]) + while (string && string[0]) { string = utf8_next_char (string); length++; @@ -250,7 +250,7 @@ utf8_strnlen (char *string, int bytes) start = string; length = 0; - while (string[0] && (string - start < bytes)) + while (string && string[0] && (string - start < bytes)) { string = utf8_next_char (string); length++; @@ -306,7 +306,7 @@ utf8_add_offset (char *string, int offset) return string + offset; count = 0; - while (string[0] && (count < offset)) + while (string && string[0] && (count < offset)) { string = utf8_next_char (string); count++; @@ -330,7 +330,7 @@ utf8_real_pos (char *string, int pos) count = 0; real_pos = 0; - while (string[0] && (count < pos)) + while (string && string[0] && (count < pos)) { next_char = utf8_next_char (string); real_pos += (next_char - string); @@ -356,7 +356,7 @@ utf8_pos (char *string, int real_pos) count = 0; limit = string + real_pos; - while (string[0] && (string < limit)) + while (string && string[0] && (string < limit)) { string = utf8_next_char (string); count++; diff --git a/src/gui/curses/gui-curses-color.c b/src/gui/curses/gui-curses-color.c index da8cee765..a180fee41 100644 --- a/src/gui/curses/gui-curses-color.c +++ b/src/gui/curses/gui-curses-color.c @@ -480,7 +480,7 @@ gui_color_init_pairs () if (has_colors ()) { - for (i = 1; i < COLOR_PAIRS; i++) + for (i = 1; i < 64; i++) init_pair (i, shift_colors[i % 8], (i < 8) ? -1 : shift_colors[i / 8]); /* disable white on white, replaced by black on white */ diff --git a/weechat/ChangeLog b/weechat/ChangeLog index baca9a512..a0a067528 100644 --- a/weechat/ChangeLog +++ b/weechat/ChangeLog @@ -4,6 +4,8 @@ WeeChat - Wee Enhanced Environment for Chat ChangeLog - 2006-05-14 Version 0.1.9 (under dev!): + * fixed crash with malformed UTF-8 strings + * fixed crash with ncurses color when too many colors defined in ncurses * added new key to find previous completion (shift-tab by default) * fixed bug with long outgoing IRC messages (> 512 bytes) (bug #16358) * fixed Ruby crash when handler does not return OK or KO (bug #16552) diff --git a/weechat/src/common/utf8.c b/weechat/src/common/utf8.c index 633aba411..11aa60808 100644 --- a/weechat/src/common/utf8.c +++ b/weechat/src/common/utf8.c @@ -65,7 +65,7 @@ utf8_init () int utf8_is_valid (char *string) { - while (string[0]) + while (string && string[0]) { /* UTF-8, 2 bytes, should be: 110vvvvv 10vvvvvv */ if (((unsigned char)(string[0]) & 0xE0) == 0xC0) @@ -219,7 +219,7 @@ utf8_strlen (char *string) return strlen (string); length = 0; - while (string[0]) + while (string && string[0]) { string = utf8_next_char (string); length++; @@ -250,7 +250,7 @@ utf8_strnlen (char *string, int bytes) start = string; length = 0; - while (string[0] && (string - start < bytes)) + while (string && string[0] && (string - start < bytes)) { string = utf8_next_char (string); length++; @@ -306,7 +306,7 @@ utf8_add_offset (char *string, int offset) return string + offset; count = 0; - while (string[0] && (count < offset)) + while (string && string[0] && (count < offset)) { string = utf8_next_char (string); count++; @@ -330,7 +330,7 @@ utf8_real_pos (char *string, int pos) count = 0; real_pos = 0; - while (string[0] && (count < pos)) + while (string && string[0] && (count < pos)) { next_char = utf8_next_char (string); real_pos += (next_char - string); @@ -356,7 +356,7 @@ utf8_pos (char *string, int real_pos) count = 0; limit = string + real_pos; - while (string[0] && (string < limit)) + while (string && string[0] && (string < limit)) { string = utf8_next_char (string); count++; diff --git a/weechat/src/gui/curses/gui-curses-color.c b/weechat/src/gui/curses/gui-curses-color.c index da8cee765..a180fee41 100644 --- a/weechat/src/gui/curses/gui-curses-color.c +++ b/weechat/src/gui/curses/gui-curses-color.c @@ -480,7 +480,7 @@ gui_color_init_pairs () if (has_colors ()) { - for (i = 1; i < COLOR_PAIRS; i++) + for (i = 1; i < 64; i++) init_pair (i, shift_colors[i % 8], (i < 8) ? -1 : shift_colors[i / 8]); /* disable white on white, replaced by black on white */