nvi-10-no_one_line_visual.patch (852B)
1 #! /bin/sh /usr/share/dpatch/dpatch-run 2 ## 10no_one_line_visual.dpatch by <hesso@pool.math.tu-berlin.de> 3 ## 4 ## DP: Catch segfaults when the screen is only one line high. 5 6 @DPATCH@ 7 diff -Naur nvi-1.81.6.orig/vi/vi.c nvi-1.81.6/vi/vi.c 8 --- nvi-1.81.6.orig/vi/vi.c 2007-11-18 17:41:42.000000000 +0100 9 +++ nvi-1.81.6/vi/vi.c 2008-05-01 18:15:14.000000000 +0200 10 @@ -974,6 +974,14 @@ 11 sp->rows = vip->srows = O_VAL(sp, O_LINES); 12 sp->cols = O_VAL(sp, O_COLUMNS); 13 sp->t_rows = sp->t_minrows = O_VAL(sp, O_WINDOW); 14 + /* 15 + * To avoid segfaults on terminals with only one line, 16 + * catch this corner case now and die explicitly. 17 + */ 18 + if (sp->t_rows == 0) { 19 + (void)fprintf(stderr, "Error: Screen too small for visual mode.\n"); 20 + return 1; 21 + } 22 if (sp->rows != 1) { 23 if (sp->t_rows > sp->rows - 1) { 24 sp->t_minrows = sp->t_rows = sp->rows - 1;