From: Foxe Chen Date: Mon, 1 Jun 2026 21:08:20 +0000 (+0000) Subject: patch 9.2.0586: Crash with TextPut autocmd when pasting in terminal buffer X-Git-Tag: v9.2.0586^0 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=2e7833bde99295be6da67d75c16d2185712ffc3a;p=thirdparty%2Fvim.git patch 9.2.0586: Crash with TextPut autocmd when pasting in terminal buffer Problem: Crash with TextPut autocmd when pasting in normal mode in a terminal buffer. Solution: Skip the TextPut autocmds when reg and insert are both NULL and regname is not '.' (Foxe Chen). closes: #20407 Signed-off-by: Foxe Chen Signed-off-by: Christian Brabandt --- diff --git a/src/register.c b/src/register.c index 9daa7729e8..358fe6454f 100644 --- a/src/register.c +++ b/src/register.c @@ -1190,6 +1190,11 @@ put_do_autocmd( if (recursive || regname == '_') return; + if (regname != '.' && insert == NULL + && reg == NULL) + // Can happen when pasting text in normal mode in a terminal buffer + return; + v_event = get_v_event(&save_v_event); list = list_alloc(); @@ -1219,7 +1224,6 @@ put_do_autocmd( } else { - assert(reg != NULL); for (n = 0; n < reg->y_size; n++) list_append_string(list, reg->y_array[n].string, (int)reg->y_array[n].length); diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim index a1f282e06d..54116a5857 100644 --- a/src/testdir/test_autocmd.vim +++ b/src/testdir/test_autocmd.vim @@ -6094,7 +6094,35 @@ func Test_TextPutX() unlet g:post_event unlet g:pre_event bwipe! +endfunc + +" Test that attempting to put text in normal mode terminal buffer does not +" result in a crash. This only happens when terminal is only window in tabpage +" it seems. +func Test_TextPutPost_term_norm() + CheckFeature terminal + + tabnew + term ++curwin + + let bnr = bufnr('$') + call WaitForAssert({-> assert_equal('running', term_getstatus(bnr))}) + + call feedkeys("\\", 'xt') + call WaitForAssert({-> assert_equal('running,normal', term_getstatus(bnr))}) + let err = 0 + + try + call feedkeys("p", 'xt') + catch /^Vim\%((\S\+)\)\=:E21:/ + let err = 1 + endtry + + call assert_true(err) + + unlet err + bwipe! endfunc " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index be7bb521b4..e020aedc51 100644 --- a/src/version.c +++ b/src/version.c @@ -729,6 +729,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 586, /**/ 585, /**/