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.
This commit is contained in:
Daniel Eklöf 2019-11-29 23:36:04 +01:00
parent bf9a9e7b90
commit 8b7158703d
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -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]);