lichray/nvi2 — pull request #6 by bentley (2013-05-19 23:47:09+00:00)
Title: Fix possible ^W crash.

I agree, this is not the same crash as in Issue #1, but I did hit this one today (checked the backtrace). :)

Original commit message by millert@openbsd:
When ^W (WERASE) is hit in insert mode it's possible that the line
buffer is accessed out of bounds. If 'max' == 0 and 'tp->cno' == 1
the 'tp->cno' value is first reduced by one and then 'tp->lb' is
accessed at 'tp->cno' - 1. Also remove dead (and incorrect) code
in the TXT_ALTWERASE case. From Arto Jonsson; OK martynas@

backtrace, for reference:
#0 0x00001fe3be94466c in v_txt (sp=0x1fe5ca899630, vp=0x7f7fffff95a0, tm=Variable "tm" is not available.
)
at /usr/ports/pobj/nvi-2.1.1-iconv/nvi-2.1.1/vi/v_txt.c:1132
#1 0x00001fe3be93c867 in v_change (sp=0x1fe5ca899630, vp=0x7f7fffff95a0)
at /usr/ports/pobj/nvi-2.1.1-iconv/nvi-2.1.1/vi/v_itxt.c:314
#2 0x00001fe3be948531 in vi (spp=0x7f7fffff97b8)
at /usr/ports/pobj/nvi-2.1.1-iconv/nvi-2.1.1/vi/vi.c:229
#3 0x00001fe3be91773a in editor (gp=0x1fe5ce7cf000, argc=2,
argv=0x7f7fffff99a8)
at /usr/ports/pobj/nvi-2.1.1-iconv/nvi-2.1.1/common/main.c:421
#4 0x00001fe3be90d4d1 in main (argc=2, argv=0x7f7fffff99a0)
at /usr/ports/pobj/nvi-2.1.1-iconv/nvi-2.1.1/cl/cl_main.c:120