It is incorrect to check the condition (offset < 0 || len < offset).
This caused messed up contents of the bottom window after a resize.
rbe = ringbuffer_get(bot_win_rb, fvr);
if (!rbe)
return -1;
- /* first rbe might be only partially visible */
- offset = (*lines - bot.lines) * bot.cols;
len = strlen(rbe->msg);
- if (offset < 0 || len < offset)
- return -1;
+ if (*lines > bot.lines) {
+ /* first rbe is only partially visible */
+ offset = (*lines - bot.lines) * bot.cols;
+ assert(offset <= len);
+ } else
+ offset = 0;
wattron(bot.win, COLOR_PAIR(rbe->color));
waddstr(bot.win, rbe->msg + offset);
*lines = NUM_LINES(len - offset);