[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2] Fix segfault when restoring w_alt.cursor
From: |
Michael Spang |
Subject: |
[PATCH v2] Fix segfault when restoring w_alt.cursor |
Date: |
Fri, 10 Aug 2012 15:24:53 -0400 |
Screen can be segfaulted with the following steps:
- Start screen
- Enable altscreen with ":altscreen on"
- Enable caption with ":caption always"
- Run vim
- Resize the current terminal to one line high
- Resize the current terminal to multiple lines high
- Quit vim
This happens because if the canvas height is 0, the alt cursor will be
adjusted to he - 1 == -1. When we later restore this cursor screen
crashes. I've reordered the sanity checks for w_saved in case there is
a similar bug for the saved cursor.
---
This fixes the same bug as the previous patch "Forbid creation of
zero-height canvas".
ChangeLog
v2 - This is a less paranoid version that just fixes the one
problematic path. It allows screen to render correctly when the only
available line is taken by the caption.
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;
--
1.7.7.3