From b4f6fcd3948cc6ed6013a2b59996dbb7e743b88a Mon Sep 17 00:00:00 2001 From: Sheldon Hearn Date: Thu, 31 Jan 2002 13:28:37 +0000 Subject: [PATCH] Fix core dump in left-right screen scrolling for long lines. The nvi maintainer expects this patch to be included in the upcoming nvi-1.81.6 unless a better fix presents itself. The MFC reminder below should be taken as a cue to MFC rev 1.1.1.2 of vs_relative.c as well. PR: bin/26869 Reported by: Alex Semenyaka Obtained from: skimo@kotnet.org (via "Alexey V. Neyman" ) MFC after: 1 month --- contrib/nvi/vi/vs_line.c | 5 ++++- contrib/nvi/vi/vs_smap.c | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/contrib/nvi/vi/vs_line.c b/contrib/nvi/vi/vs_line.c index b439de925ce1..e48d5ef5e917 100644 --- a/contrib/nvi/vi/vs_line.c +++ b/contrib/nvi/vi/vs_line.c @@ -267,7 +267,10 @@ empty: (void)gp->scr_addstr(sp, cols_per_screen = sp->cols; /* Put starting info for this line in the cache. */ - if (scno != skip_cols) { + if (offset_in_line >= len) { + smp->c_sboff = offset_in_line; + smp->c_scoff = 255; + } else if (scno != skip_cols) { smp->c_sboff = offset_in_line; smp->c_scoff = offset_in_char = chlen - (scno - skip_cols); diff --git a/contrib/nvi/vi/vs_smap.c b/contrib/nvi/vi/vs_smap.c index af38057e815f..18d7942b742a 100644 --- a/contrib/nvi/vi/vs_smap.c +++ b/contrib/nvi/vi/vs_smap.c @@ -743,7 +743,7 @@ vs_sm_up(sp, rp, count, scmd, smp) if (!SMAP_CACHE(smp) && vs_line(sp, smp, NULL, NULL)) return (1); rp->lno = smp->lno; - rp->cno = smp->c_sboff; + rp->cno = smp->c_scoff == 255 ? 0 : smp->c_sboff; return (0); } @@ -958,7 +958,7 @@ vs_sm_down(sp, rp, count, scmd, smp) if (!SMAP_CACHE(smp) && vs_line(sp, smp, NULL, NULL)) return (1); rp->lno = smp->lno; - rp->cno = smp->c_sboff; + rp->cno = smp->c_scoff == 255 ? 0 : smp->c_sboff; return (0); }