1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 09:27:59 +00:00

Missing NULL check in swap_screen.

Coverity points out that this function is mostly written as if it's
intended to allow for term->screen and/or term->alt_screen to be NULL,
but makes an unguarded call to find_last_nonempty_line on one of them.

I don't immediately remember _why_ I needed to deal with those
pointers being null, but it was probably a safety precaution against
swap_screen being called during setup or during reconfiguration, in
which case it seems sensible to keep it even if it's not needed in the
_current_ state of the code. So, added the missing check.
This commit is contained in:
Simon Tatham 2020-06-16 18:02:39 +01:00
parent 41053e9dcd
commit 2316b44426

View File

@ -2066,7 +2066,9 @@ static void swap_screen(Terminal *term, int which,
ttr = term->alt_screen;
term->alt_screen = term->screen;
term->screen = ttr;
term->alt_sblines = find_last_nonempty_line(term, term->alt_screen) + 1;
term->alt_sblines = (
term->alt_screen ?
find_last_nonempty_line(term, term->alt_screen) + 1 : 0);
t = term->curs.x;
if (!reset && !keep_cur_pos)
term->curs.x = term->alt_x;