diff options
author | Kevin McCarthy <kevin@8t8.us> | 2021-04-13 18:02:31 -0700 |
---|---|---|
committer | Kevin McCarthy <kevin@8t8.us> | 2021-04-15 17:58:56 -0700 |
commit | 0684a051821283fc0af5f9b836b37a02720948a2 (patch) | |
tree | 39ab73625e26c1a2e3422d1c7d187658310338c0 | |
parent | 2d6832011debd96324037eee1ccbdfba1903b197 (diff) |
Add a check to make sure pair doesn't overflow.
It's not clear if COLOR_PAIRS can be larger than SHRT_MAX + 1, so make
sure with a check.
-rw-r--r-- | color.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -370,6 +370,12 @@ static int _mutt_alloc_color (int fg, int bg, int type) * to COLOR_PAIRS-1 pairs. */ if (UserColors >= (COLOR_PAIRS - 1)) return (0); + + /* Check for pair overflow too. We are currently using init_pair(), which + * only accepts size short. */ + if ((pair > SHRT_MAX) || (pair < 0)) + return (0); + UserColors++; p = (COLOR_LIST *) safe_calloc (1, sizeof (COLOR_LIST)); |