From f76d23601543eee605be848f8607bf0ba52c2e5f Mon Sep 17 00:00:00 2001 From: Mario Campos Date: Fri, 8 Mar 2024 23:11:30 -0600 Subject: GUI: fix potential integer overflow bugs by casting to `size_t` --- src/gui/curses/gui-curses-color.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gui/curses/gui-curses-color.c') diff --git a/src/gui/curses/gui-curses-color.c b/src/gui/curses/gui-curses-color.c index 705986be2..af71bfd9a 100644 --- a/src/gui/curses/gui-curses-color.c +++ b/src/gui/curses/gui-curses-color.c @@ -669,7 +669,7 @@ gui_color_init_vars () gui_color_num_pairs = (gui_color_term_color_pairs >= 32768) ? 32767 : gui_color_term_color_pairs - 1; gui_color_pairs = calloc ( - (gui_color_term_colors + 2) * (gui_color_term_colors + 2), + (size_t)(gui_color_term_colors + 2) * (gui_color_term_colors + 2), sizeof (gui_color_pairs[0])); gui_color_pairs_used = 0; @@ -1226,7 +1226,7 @@ gui_color_reset_pairs () if (gui_color_pairs) { memset (gui_color_pairs, 0, - (gui_color_term_colors + 2) + (size_t)(gui_color_term_colors + 2) * (gui_color_term_colors + 2) * sizeof (gui_color_pairs[0])); gui_color_pairs_used = 0; -- cgit v1.2.3