summaryrefslogtreecommitdiff
path: root/src/term.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2013-06-30 17:51:51 +0200
committerBram Moolenaar <Bram@vim.org>2013-06-30 17:51:51 +0200
commite057d40d967a8223a34fe5b56ffb00dfd06e4cd4 (patch)
tree3c14b2bf97d6bb23721a33dfba7704b5fa91f6b5 /src/term.c
parent5a4d51e6929b1bb615eaf212a091384cc266b8d7 (diff)
downloadvim-e057d40d967a8223a34fe5b56ffb00dfd06e4cd4.zip
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.
Diffstat (limited to 'src/term.c')
-rw-r--r--src/term.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/term.c b/src/term.c
index 003dd8b1a..c2c5cf8db 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2962,15 +2962,29 @@ get_bytes_from_buf(buf, bytes, num_bytes)
#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;
}
/*