summaryrefslogtreecommitdiff
path: root/src/screen.c
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-10-15 12:40:44 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-10-15 12:40:44 +0300
commit7b31d6a05357953c035e2ab05ec117ef748f7798 (patch)
tree26fea99ff05dce6f076b74e35a19c14a53762653 /src/screen.c
parentca69844a243a6e335b0ddafad057f35e89e0a576 (diff)
Reject a scrollback above TERM_SCROLLBACK_MAX
term_new() silently cut a scrollback above 1000000 lines to 1000000. The limit now has a name in term.h, and term_new() returns NULL above it, as it does for the other invalid options. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'src/screen.c')
-rw-r--r--src/screen.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/screen.c b/src/screen.c
index b99948d..ab6989a 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -808,12 +808,10 @@ void term_screen_set_alternate(struct term *t, bool enabled)
}
}
-/* The caller has checked that requested is not negative. */
+/* The caller has checked that requested is in [0, TERM_SCROLLBACK_MAX]. */
static int scrollback_lines(int requested)
{
- if (requested == 0)
- return TERM_SCROLLBACK_DEFAULT;
- return requested > 1000000 ? 1000000 : requested;
+ return requested == 0 ? TERM_SCROLLBACK_DEFAULT : requested;
}
static atomic_int tables_state;
@@ -862,7 +860,8 @@ struct term *term_new(const struct term_options *opt)
return NULL;
if (opt->size.x < 0 || opt->size.y < 0 || opt->size.x > TERM_MAX_COLS)
return NULL;
- if (opt->scrollback < 0 || (unsigned)opt->cursor_style > TERM_CURSOR_BAR)
+ if (opt->scrollback < 0 || opt->scrollback > TERM_SCROLLBACK_MAX ||
+ (unsigned)opt->cursor_style > TERM_CURSOR_BAR)
return NULL;
const char *name = opt->name && *opt->name ? opt->name : "term";
if (!name_valid(name))