This is an automated email from the git hooks/post-receive script.

git pushed a commit to reference refs/pull/36/head
in repository terminology.

View the commit online.

commit 8c73f3364cb4c6b09f54f37352919565aa16b8fd
Author: [email protected] <[email protected]>
AuthorDate: Sun Mar 22 13:23:14 2026 -0600

    fix: prevent crash when scrolling to end of tymux backlog
    
    termpty_backscroll_adjust and termpty_backlog_length walk the Termsave
    backlog via BACKLOG_ROW_GET, which dereferences ty->back.  For tymux
    shadow PTYs ty->back is NULL (scrollback comes from shared-memory
    buffers via the backlog_get callback).  Add early-return guards that
    clamp to ty->backsize when the callback is set, avoiding the NULL
    dereference.
    
    Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
---
 src/bin/backlog.c | 4 ++++
 src/bin/termpty.c | 8 ++++++++
 2 files changed, 12 insertions(+)

diff --git a/src/bin/backlog.c b/src/bin/backlog.c
index a404d57c..d1f85a37 100644
--- a/src/bin/backlog.c
+++ b/src/bin/backlog.c
@@ -159,6 +159,10 @@ termpty_backlog_length(Termpty *ty)
 
    if (!ty->backsize)
      return 0;
+   /* Shadow PTY with custom backlog — ty->back is NULL, return the
+    * pre-computed backsize which is kept up to date by termsession. */
+   if (ty->backlog_get.func)
+     return (ssize_t)ty->backsize;
 
    for (backlog_y++; backlog_y < (int)ty->backsize; backlog_y++)
      {
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index 50377650..00cce302 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -1043,6 +1043,14 @@ termpty_backscroll_adjust(Termpty *ty, int *scroll)
         *scroll = 0;
         return;
      }
+   /* Shadow PTY with custom backlog — clamp and return without
+    * touching the Termsave-based backlog (ty->back may be NULL). */
+   if (ty->backlog_get.func)
+     {
+        if (*scroll > (int)ty->backsize)
+          *scroll = (int)ty->backsize;
+        return;
+     }
    if (*scroll < screen_y)
      {
         return;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to