Fix segfaults in terminal resizing, introduced by re-engineering.
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Wed, 13 Oct 2004 13:35:29 +0000 (13:35 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Wed, 13 Oct 2004 13:35:29 +0000 (13:35 +0000)
git-svn-id: svn://svn.tartarus.org/sgt/putty@4613 cda61777-01e9-0310-a592-d414129be87e

terminal.c

index d091162..0221a56 100644 (file)
@@ -115,8 +115,10 @@ static termline *newline(Terminal *term, int cols, int bce)
 
 static void freeline(termline *line)
 {
-    sfree(line->chars);
-    sfree(line);
+    if (line) {
+       sfree(line->chars);
+       sfree(line);
+    }
 }
 
 static void unlineptr(termline *line)
@@ -1003,7 +1005,7 @@ void term_size(Terminal *term, int newrows, int newcols, int newsavelines)
 {
     tree234 *newalt;
     termline **newdisp, *line;
-    int i, j;
+    int i, j, oldrows = term->rows;
     int sblen;
     int save_alt_which = term->alt_which;
 
@@ -1105,7 +1107,7 @@ void term_size(Terminal *term, int newrows, int newcols, int newsavelines)
            newdisp[i]->chars[i].attr = ATTR_INVALID;
     }
     if (term->disptext) {
-       for (i = 0; i < term->rows; i++)
+       for (i = 0; i < oldrows; i++)
            freeline(term->disptext[i]);
     }
     sfree(term->disptext);