From: zeertzjq Date: Wed, 28 Jan 2026 21:36:51 +0000 (+0000) Subject: patch 9.1.2112: long statusline may crash if using singlebyte encoding X-Git-Tag: v9.1.2112^0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f7be0d7e1a394797c44090cdb9a231f1424187d;p=thirdparty%2Fvim.git patch 9.1.2112: long statusline may crash if using singlebyte encoding Problem: long statusline may crash if using singlebyte encoding (fizz-is-on-the-way) Solution: Drop the non-mbyte codepath and always use the mbyte code (zeertzjq) Signed-off-by: zeertzjq Signed-off-by: Christian Brabandt --- diff --git a/src/buffer.c b/src/buffer.c index 62f236ff0b..86b7840230 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -5264,17 +5264,12 @@ build_stl_str_hl( { char_u *end = out + outputlen; - if (has_mbyte) + n = 0; + while (width >= maxwidth) { - n = 0; - while (width >= maxwidth) - { - width -= ptr2cells(s + n); - n += (*mb_ptr2len)(s + n); - } + width -= ptr2cells(s + n); + n += (*mb_ptr2len)(s + n); } - else - n = width - maxwidth + 1; p = s + n; mch_memmove(s + 1, p, (size_t)(end - p) + 1); // +1 for NUL end -= (size_t)(p - (s + 1)); diff --git a/src/testdir/test_statusline.vim b/src/testdir/test_statusline.vim index 4899bd0a05..174c1a4754 100644 --- a/src/testdir/test_statusline.vim +++ b/src/testdir/test_statusline.vim @@ -707,4 +707,18 @@ func Test_statusline_in_sandbox() delfunc Check_statusline_in_sandbox endfunc +" This used to call memmove with a negative size and crash Vim +func Test_statusline_singlebyte_negative() + let [_columns, _ls, _stl, _enc] = [&columns, &ls, &stl, &enc] + set encoding=latin1 + set laststatus=2 columns=15 + setl stl=%#ErrorMsg#abcdtàØ?}}o@`s`ÿæCú\xE%#Normal# + vsp + setl stl=%#ErrorMsg#abcdtàØ?}}o@`s`ÿæCú\xE%#Normal# + redraw! + redrawstatus + bw! + let [&columns, &ls, &stl, &enc] = [_columns, _ls, _stl, _enc] +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index de16a77a48..f989c2ae4c 100644 --- a/src/version.c +++ b/src/version.c @@ -734,6 +734,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2112, /**/ 2111, /**/