summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2006-05-14 11:06:16 +0000
committerSebastien Helleu <flashcode@flashtux.org>2006-05-14 11:06:16 +0000
commit631eab3c663c5b1a15f651141a2001e50c9ff6a9 (patch)
tree787a51be1b0c4e3e9a02fe01f57aafdb26730fde /src
parent141889710872d8f69cab853431bcde0cf1c68461 (diff)
downloadweechat-631eab3c663c5b1a15f651141a2001e50c9ff6a9.zip
Fixed 2 crashs: with malformed UTF-8 strings and with ncurses color when too many colors defined in ncurses
Diffstat (limited to 'src')
-rw-r--r--src/common/utf8.c12
-rw-r--r--src/gui/curses/gui-curses-color.c2
2 files changed, 7 insertions, 7 deletions
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 */