mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-14 08:21:27 -04:00
commit
22307565ac
2 changed files with 21 additions and 10 deletions
|
|
@ -57,6 +57,8 @@
|
||||||
ongoing (https://codeberg.org/dnkl/foot/issues/922).
|
ongoing (https://codeberg.org/dnkl/foot/issues/922).
|
||||||
* Large selections crossing the scrollback wrap-around
|
* Large selections crossing the scrollback wrap-around
|
||||||
(https://codeberg.org/dnkl/foot/issues/924).
|
(https://codeberg.org/dnkl/foot/issues/924).
|
||||||
|
* Crash in `pipe-scrollback`
|
||||||
|
(https://codeberg.org/dnkl/foot/issues/926).
|
||||||
|
|
||||||
|
|
||||||
### Security
|
### Security
|
||||||
|
|
|
||||||
29
terminal.c
29
terminal.c
|
|
@ -3414,16 +3414,22 @@ rows_to_text(const struct terminal *term, int start, int end,
|
||||||
if (ctx == NULL)
|
if (ctx == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (size_t r = start;
|
const int grid_rows = term->grid->num_rows;
|
||||||
r != ((end + 1) & (term->grid->num_rows - 1));
|
int r = start;
|
||||||
r = (r + 1) & (term->grid->num_rows - 1))
|
|
||||||
{
|
while (true) {
|
||||||
const struct row *row = term->grid->rows[r];
|
const struct row *row = term->grid->rows[r];
|
||||||
xassert(row != NULL);
|
xassert(row != NULL);
|
||||||
|
|
||||||
for (int c = 0; c < term->cols; c++)
|
for (int c = 0; c < term->cols; c++)
|
||||||
if (!extract_one(term, row, &row->cells[c], c, ctx))
|
if (!extract_one(term, row, &row->cells[c], c, ctx))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
if (r == end)
|
||||||
|
break;
|
||||||
|
|
||||||
|
r++;
|
||||||
|
r &= grid_rows - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
@ -3433,19 +3439,22 @@ out:
|
||||||
bool
|
bool
|
||||||
term_scrollback_to_text(const struct terminal *term, char **text, size_t *len)
|
term_scrollback_to_text(const struct terminal *term, char **text, size_t *len)
|
||||||
{
|
{
|
||||||
int start = term->grid->offset + term->rows;
|
const int grid_rows = term->grid->num_rows;
|
||||||
int end = term->grid->offset + term->rows - 1;
|
int start = (term->grid->offset + term->rows) & (grid_rows - 1);
|
||||||
|
int end = (term->grid->offset + term->rows - 1) & (grid_rows - 1);
|
||||||
|
|
||||||
|
xassert(start >= 0);
|
||||||
|
xassert(start < grid_rows);
|
||||||
|
xassert(end >= 0);
|
||||||
|
xassert(end < grid_rows);
|
||||||
|
|
||||||
/* If scrollback isn't full yet, this may be NULL, so scan forward
|
/* If scrollback isn't full yet, this may be NULL, so scan forward
|
||||||
* until we find the first non-NULL row */
|
* until we find the first non-NULL row */
|
||||||
while (term->grid->rows[start] == NULL) {
|
while (term->grid->rows[start] == NULL) {
|
||||||
start++;
|
start++;
|
||||||
start &= term->grid->num_rows - 1;
|
start &= grid_rows - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (end < 0)
|
|
||||||
end += term->grid->num_rows;
|
|
||||||
|
|
||||||
while (term->grid->rows[end] == NULL) {
|
while (term->grid->rows[end] == NULL) {
|
||||||
end--;
|
end--;
|
||||||
if (end < 0)
|
if (end < 0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue