diff options
author | Michael Spang <spang@google.com> | 2012-09-14 22:46:20 -0400 |
---|---|---|
committer | Sadrul Habib Chowdhury <sadrul@users.sourceforge.net> | 2012-09-14 22:46:20 -0400 |
commit | 548eebae59f7b91b55587cfe5b580eb02a2d416d (patch) | |
tree | 4af17c27ee48caef55af90f20a55541d5ff8ac5e | |
parent | b4a43d4b67a753b2af93fc3a1c85dd9aa0378ef8 (diff) | |
download | screen-548eebae59f7b91b55587cfe5b580eb02a2d416d.tar.gz |
Fix segfault when restoring w_alt.cursor.
This fixes a crash when the window is made too small (zero height).
The crash can be reproduced by turning on altscreen and caption, and
resizing the terminal window to height = 1. After this, if the
termianl window height is increased, screen would crash when going
out of the alt screen.
-rw-r--r-- | src/resize.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/resize.c b/src/resize.c index 0e491eb..3c2b90f 100644 --- a/src/resize.c +++ b/src/resize.c @@ -966,14 +966,16 @@ int wi, he, hi; p->w_y = he - 1; if (p->w_saved.x > wi) p->w_saved.x = wi; - if (p->w_saved.y < 0) - p->w_saved.y = 0; if (p->w_saved.y >= he) p->w_saved.y = he - 1; + if (p->w_saved.y < 0) + p->w_saved.y = 0; if (p->w_alt.cursor.x > wi) p->w_alt.cursor.x = wi; if (p->w_alt.cursor.y >= he) p->w_alt.cursor.y = he - 1; + if (p->w_alt.cursor.y < 0) + p->w_alt.cursor.y = 0; /* reset scrolling region */ p->w_top = 0; |