updated for version 7.3.1278
Problem: When someone sets the screen size to a huge value with "stty" Vim
runs out of memory before reducing the size.
Solution: Limit Rows and Columns in more places.
diff --git a/src/term.c b/src/term.c
index 003dd8b..c2c5cf8 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2962,15 +2962,29 @@
#endif
/*
- * Check if the new shell size is valid, correct it if it's too small.
+ * Check if the new shell size is valid, correct it if it's too small or way
+ * too big.
*/
void
check_shellsize()
{
- if (Columns < MIN_COLUMNS)
- Columns = MIN_COLUMNS;
if (Rows < min_rows()) /* need room for one window and command line */
Rows = min_rows();
+ limit_screen_size();
+}
+
+/*
+ * Limit Rows and Columns to avoid an overflow in Rows * Columns.
+ */
+ void
+limit_screen_size()
+{
+ if (Columns < MIN_COLUMNS)
+ Columns = MIN_COLUMNS;
+ else if (Columns > 10000)
+ Columns = 10000;
+ if (Rows > 1000)
+ Rows = 1000;
}
/*