diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2011-04-11 14:45:05 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2011-04-11 14:45:05 +0200 |
commit | 25684ad8a63f75a06fa444965cd17e2f7fe0db08 (patch) | |
tree | 7c57d603c2caef8dc2cf699d8467e89246dabd5b /src | |
parent | 9d128cad2279ff070d8204e1d3d7003f379c58da (diff) | |
download | weechat-25684ad8a63f75a06fa444965cd17e2f7fe0db08.zip |
core: fix crash when terminal has no color support
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/curses/gui-curses-color.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/src/gui/curses/gui-curses-color.c b/src/gui/curses/gui-curses-color.c index 6347f1633..00c8e7133 100644 --- a/src/gui/curses/gui-curses-color.c +++ b/src/gui/curses/gui-curses-color.c @@ -523,16 +523,14 @@ gui_color_init_vars () gui_color_num_pairs = (gui_color_term_color_pairs >= 256) ? 255 : gui_color_term_color_pairs - 1; - if (gui_color_term_colors > 0) - { - size = (gui_color_term_colors + 2) - * (gui_color_term_colors + 2) - * sizeof (gui_color_pairs[0]); - gui_color_pairs = malloc (size); - if (gui_color_pairs) - memset (gui_color_pairs, 0, size); - gui_color_pairs_used = 0; - } + size = (gui_color_term_colors + 2) + * (gui_color_term_colors + 2) + * sizeof (gui_color_pairs[0]); + gui_color_pairs = malloc (size); + if (gui_color_pairs) + memset (gui_color_pairs, 0, size); + gui_color_pairs_used = 0; + /* reserved for future usage */ /* gui_color_term_color_content = malloc (sizeof (gui_color_term_color_content[0]) * @@ -549,6 +547,18 @@ gui_color_init_vars () } */ } + else + { + gui_color_term_colors = 1; + gui_color_term_color_pairs = 1; + gui_color_term_can_change_color = 0; + gui_color_num_pairs = 1; + size = sizeof (gui_color_pairs[0]); + gui_color_pairs = malloc (size); + if (gui_color_pairs) + memset (gui_color_pairs, 0, size); + gui_color_pairs_used = 0; + } } /* |