endline_for_mb() and its single-byte twin endline() advance the scan
pointer twice when the last character of a buffer-filling line is a tab
(once in the tab branch, once via the shared *++p) with no terminator
re-check in between. A full line (wl == READBUF-1) ending in a tab makes
*++p read wbuf[READBUF] and the following *end = L'\0' write it -- one
element past the wbuf[READBUF] array.
Re-check for the terminator before the second advance.
Closes #4495
Signed-off-by: logical-misha <220645577+logical-misha@users.noreply.github.com>
* Assume the terminal will print the
* entire character onto the next row. */
p--;
- if (*++p == L'\n')
+ if (*p != L'\0' && *++p == L'\n')
p++;
end = p;
goto ended;
if (pos > col) {
if (*s == '\t')
s++;
- if (*++s == '\n')
+ if (*s != '\0' && *++s == '\n')
s++;
t = s;
goto cend;