diff --git a/terminal.c b/terminal.c index 8f65a73e..08556d02 100644 --- a/terminal.c +++ b/terminal.c @@ -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;