Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
5069:44f2eb39f49e | 5070:cf52d2a8c05c |
---|---|
2960 return len; | 2960 return len; |
2961 } | 2961 } |
2962 #endif | 2962 #endif |
2963 | 2963 |
2964 /* | 2964 /* |
2965 * Check if the new shell size is valid, correct it if it's too small. | 2965 * Check if the new shell size is valid, correct it if it's too small or way |
2966 * too big. | |
2966 */ | 2967 */ |
2967 void | 2968 void |
2968 check_shellsize() | 2969 check_shellsize() |
2969 { | 2970 { |
2971 if (Rows < min_rows()) /* need room for one window and command line */ | |
2972 Rows = min_rows(); | |
2973 limit_screen_size(); | |
2974 } | |
2975 | |
2976 /* | |
2977 * Limit Rows and Columns to avoid an overflow in Rows * Columns. | |
2978 */ | |
2979 void | |
2980 limit_screen_size() | |
2981 { | |
2970 if (Columns < MIN_COLUMNS) | 2982 if (Columns < MIN_COLUMNS) |
2971 Columns = MIN_COLUMNS; | 2983 Columns = MIN_COLUMNS; |
2972 if (Rows < min_rows()) /* need room for one window and command line */ | 2984 else if (Columns > 10000) |
2973 Rows = min_rows(); | 2985 Columns = 10000; |
2986 if (Rows > 1000) | |
2987 Rows = 1000; | |
2974 } | 2988 } |
2975 | 2989 |
2976 /* | 2990 /* |
2977 * Invoked just before the screen structures are going to be (re)allocated. | 2991 * Invoked just before the screen structures are going to be (re)allocated. |
2978 */ | 2992 */ |