aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md3
-rw-r--r--render.c22
2 files changed, 19 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a02b9346..df098c41 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -136,6 +136,8 @@
([#1280][1280]).
* Multi-character compose sequences with the kitty keyboard protocol
([#1288][1288]).
+* Crash when application output scrolls very fast, e.g. `yes`
+ ([#1305][1305]).
[1173]: https://codeberg.org/dnkl/foot/issues/1173
[1190]: https://codeberg.org/dnkl/foot/issues/1190
@@ -147,6 +149,7 @@
[1249]: https://codeberg.org/dnkl/foot/issues/1249
[1280]: https://codeberg.org/dnkl/foot/issues/1280
[1288]: https://codeberg.org/dnkl/foot/issues/1288
+[1305]: https://codeberg.org/dnkl/foot/issues/1305
### Security
diff --git a/render.c b/render.c
index 2aba3237..f16898b4 100644
--- a/render.c
+++ b/render.c
@@ -929,14 +929,19 @@ static void
grid_render_scroll(struct terminal *term, struct buffer *buf,
const struct damage *dmg)
{
- int height = (dmg->region.end - dmg->region.start - dmg->lines) * term->cell_height;
-
LOG_DBG(
"damage: SCROLL: %d-%d by %d lines",
dmg->region.start, dmg->region.end, dmg->lines);
- if (height <= 0)
+ const int region_size = dmg->region.end - dmg->region.start;
+
+ if (dmg->lines >= region_size) {
+ /* The entire scroll region will be scrolled out (i.e. replaced) */
return;
+ }
+
+ const int height = (region_size - dmg->lines) * term->cell_height;
+ xassert(height > 0);
#if TIME_SCROLL_DAMAGE
struct timespec start_time;
@@ -1037,14 +1042,19 @@ static void
grid_render_scroll_reverse(struct terminal *term, struct buffer *buf,
const struct damage *dmg)
{
- int height = (dmg->region.end - dmg->region.start - dmg->lines) * term->cell_height;
-
LOG_DBG(
"damage: SCROLL REVERSE: %d-%d by %d lines",
dmg->region.start, dmg->region.end, dmg->lines);
- if (height <= 0)
+ const int region_size = dmg->region.end - dmg->region.start;
+
+ if (dmg->lines >= region_size) {
+ /* The entire scroll region will be scrolled out (i.e. replaced) */
return;
+ }
+
+ const int height = (region_size - dmg->lines) * term->cell_height;
+ xassert(height > 0);
#if TIME_SCROLL_DAMAGE
struct timespec start_time;