From e47f9f20d68eda78a6621917a7e100ae333a1a53 Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Thu, 15 Oct 2026 12:29:35 +0300 Subject: Reject invalid arguments instead of ignoring them term_feed() returns bool and rejects a NULL terminal, a NULL buffer with a nonzero length, and any flag bit it does not know. Unknown bits are rejected now so that later flags can be added without changing what the old calls mean. term_new() returns NULL for a negative size component, columns above TERM_MAX_COLS, a negative scrollback, or a cursor style outside the enum. Zero still selects the default size and scrollback. It no longer clamps bad values silently. term_resize() rejects columns above TERM_MAX_COLS instead of clamping them, which matches how it already rejects a size below 1. Co-Authored-By: Claude Haiku 5.5 --- benchmarks/term_write_bench.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'benchmarks') diff --git a/benchmarks/term_write_bench.c b/benchmarks/term_write_bench.c index 50853f6..7649ed8 100644 --- a/benchmarks/term_write_bench.c +++ b/benchmarks/term_write_bench.c @@ -152,7 +152,10 @@ int main(int argc, char **argv) .size = { .x = cols_val, .y = 40 }, .scrollback = BENCH_SCROLLBACK, }); - if (!t) return EXIT_FAILURE; + if (!t) { + fprintf(stderr, "term_new failed: TERM_COLS must be 0 to %d\n", TERM_MAX_COLS); + return EXIT_FAILURE; + } /* manyline has bare LFs: each one also returns the cursor to * column 0, as a tty with ONLCR does. */ unsigned flags = !strcmp(cases[c].name, "manyline") ? TERM_FEED_ONLCR : 0; -- cgit v1.2.3