]> Skullheadx's Git Forge - st.git/commitdiff
st: guard tsetdirt() against zero-sized terminal
authorMilos Nikic <nikic.milos@gmail.com>
Thu, 15 Jan 2026 05:00:32 +0000 (21:00 -0800)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Fri, 16 Jan 2026 13:12:07 +0000 (14:12 +0100)
tsetdirt() assumes term.row > 0. During early init or
resize paths this may not hold, leading to out-of-bounds
access. Bail out early if there are no rows.

st.c

diff --git a/st.c b/st.c
index e55e7b33a16e35aa48f890a26ea11fbca4c9405d..6f40e35bc8585cda6584a26d37a44014cc56627c 100644 (file)
--- a/st.c
+++ b/st.c
@@ -965,6 +965,9 @@ tsetdirt(int top, int bot)
 {
        int i;
 
+       if (term.row <= 0)
+               return;
+
        LIMIT(top, 0, term.row-1);
        LIMIT(bot, 0, term.row-1);