From 8b7158703de69d0a3977491fd9a7ec17c86c4199 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Fri, 29 Nov 2019 23:36:04 +0100 Subject: [PATCH] term: reset: don't access rows directly We've just re-set the grid offsets, meaning rows 0..term->rows may not all have been initialized. Call grid_row_and_alloc() to ensure they are. --- terminal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/terminal.c b/terminal.c index 14ee063c..28729f20 100644 --- a/terminal.c +++ b/terminal.c @@ -869,8 +869,8 @@ term_reset(struct terminal *term, bool hard) term->normal.offset = term->normal.view = 0; term->alt.offset = term->alt.view = 0; for (size_t i = 0; i < term->rows; i++) { - memset(term->normal.rows[i]->cells, 0, term->cols * sizeof(struct cell)); - memset(term->alt.rows[i]->cells, 0, term->cols * sizeof(struct cell)); + memset(grid_row_and_alloc(&term->normal, i)->cells, 0, term->cols * sizeof(struct cell)); + memset(grid_row_and_alloc(&term->alt, i)->cells, 0, term->cols * sizeof(struct cell)); } for (size_t i = term->rows; i < term->normal.num_rows; i++) { grid_row_free(term->normal.rows[i]);