diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 385cf3b4ae279b7007b01d5e57148547ebecfe47..6b8fecbac8e6430b48ef2a34d90b2197a67edbf9 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -3089,7 +3089,7 @@ append_command(char_u *cmd) STRCAT(IObuff, ": "); d = IObuff + STRLEN(IObuff); - while (*s != NUL && d - IObuff < IOSIZE - 7) + while (*s != NUL && d - IObuff + 5 < IOSIZE) { if (enc_utf8 ? (s[0] == 0xc2 && s[1] == 0xa0) : *s == 0xa0) { @@ -3097,6 +3097,8 @@ append_command(char_u *cmd) STRCPY(d, ""); d += 4; } + else if (d - IObuff + (*mb_ptr2len)(s) + 1 >= IOSIZE) + break; else MB_COPY_CHAR(s, d); } diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim index 3f73d3da34950d8a4cfc1c5091b0db913faf75dc..c977a639fd59f3d6ec2d71c1062ee1a6189aeee6 100644 --- a/src/testdir/test_cmdline.vim +++ b/src/testdir/test_cmdline.vim @@ -842,3 +842,14 @@ func Test_buffers_lastused() bwipeout bufb bwipeout bufc endfunc + +" this was going over the end of IObuff +func Test_report_error_with_composing() + let caught = 'no' + try + exe repeat('0', 987) .. "0\xdd\x80\xdd\x80\xdd\x80\xdd\x80" + catch /E492:/ + let caught = 'yes' + endtry + call assert_equal('yes', caught) +endfunc \ No newline at end of file diff --git a/src/version.c b/src/version.c index bd442f5d6fcf63c9c4fdc509148678771459fd8e..5ceb369976427dde91f11baceb1bb77b1f242779 100644 --- a/src/version.c +++ b/src/version.c @@ -741,6 +741,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2271, /**/ 2270, /**/