diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2024-04-15 14:03:30 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2024-04-15 14:03:30 +0000 |
| commit | 71ce17d97795419c3fe5d28132e387f27e2ca958 (patch) | |
| tree | 42b378509736c990063414ce425a724fa7b488fe | |
| parent | osc: reject notifications with invalid UTF-8 strings (diff) | |
term: don't print outside grid when printing multi-column characters
When auto-wrap is disabled, a multi-column character may be printed on
a line that doesn't fit the entire character. That is, the "spacers"
we print, as place holders in the columns after the first one, may
reach outside the grid.
We did (try to) check for this, but the check was off by one. Meaning,
we could, in some cases, print outside the grid.
| -rw-r--r-- | CHANGELOG.md | 3 | ||||
| -rw-r--r-- | terminal.c | 5 |
2 files changed, 7 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f3a0179..68b15356 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,9 @@ ### Deprecated ### Removed ### Fixed + +* Crash when printing double-width (or longer) characters to, or near, + the last column, when auto-wrap (private mode 7) has been disabled. ### Security ### Contributors @@ -3680,11 +3680,13 @@ term_print(struct terminal *term, char32_t wc, int width) grid_row_uri_range_erase(row, col, col + width - 1); /* Advance cursor the 'additional' columns while dirty:ing the cells */ - for (int i = 1; i < width && col < term->cols; i++) { + for (int i = 1; i < width && (col + 1) < term->cols; i++) { col++; print_spacer(term, col, width - i); } + xassert(col < term->cols); + /* Advance cursor */ if (unlikely(++col >= term->cols)) { grid->cursor.lcf = true; @@ -3726,6 +3728,7 @@ ascii_printer_fast(struct terminal *term, char32_t wc) /* Advance cursor */ if (unlikely(++col >= term->cols)) { + xassert(col == term->cols); grid->cursor.lcf = true; col--; } else |
