{
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));
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àØ\7f?}}o@`s`ÿæ\ 3Cú\x\ 5E%#Normal#
+ vsp
+ setl stl=%#ErrorMsg#abcdtàØ\7f?}}o@`s`ÿæ\ 3Cú\x\ 5E%#Normal#
+ redraw!
+ redrawstatus
+ bw!
+ let [&columns, &ls, &stl, &enc] = [_columns, _ls, _stl, _enc]
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab