Mercurial > vim
diff src/term.c @ 5070:cf52d2a8c05c v7.3.1278
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.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sun, 30 Jun 2013 17:51:51 +0200 |
parents | 113768420756 |
children | 19ed30f7cef7 |
line wrap: on
line diff
--- 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 (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; - if (Rows < min_rows()) /* need room for one window and command line */ - Rows = min_rows(); + else if (Columns > 10000) + Columns = 10000; + if (Rows > 1000) + Rows = 1000; } /*