patch 9.1.1143: illegal memory access when putting a register Commit: https://github.com/vim/vim/commit/e0029daa3599529d9d438cc51c7ada8580297a39 Author: Christian Brabandt <c...@256bit.org> Date: Sun Feb 23 20:01:54 2025 +0100
patch 9.1.1143: illegal memory access when putting a register Problem: illegal memory access when putting a register Solution: make sure cursor column doesn't become negative Signed-off-by: Christian Brabandt <c...@256bit.org> diff --git a/src/register.c b/src/register.c index a9630f8ef..ea54e202e 100644 --- a/src/register.c +++ b/src/register.c @@ -2249,7 +2249,7 @@ error: // Put the '] mark on the first byte of the last inserted character. // Correct the length for change in indent. curbuf->b_op_end.lnum = new_lnum; - col = (colnr_T)y_array[y_size - 1].length - lendiff; + col = MAX(0, (colnr_T)y_array[y_size - 1].length - lendiff); if (col > 1) { curbuf->b_op_end.col = col - 1; diff --git a/src/testdir/test_registers.vim b/src/testdir/test_registers.vim index ee59ecb30..252445377 100644 --- a/src/testdir/test_registers.vim +++ b/src/testdir/test_registers.vim @@ -1123,4 +1123,21 @@ func Test_register_redir_display() call setreg(1, a[0], a[1]) endfunc +" this caused an illegal memory access and a crash +func Test_register_cursor_column_negative() + CheckRunVimInTerminal + let script =<< trim END + f XREGISTER + call setline(1, 'abcdef a') + call setreg("a", " ", 'c') + call cursor(1, 7) + call feedkeys("i\<C-R>\<C-P>azyx$#\<esc>", 't') + END + call writefile(script, 'XRegister123', 'D') + let buf = RunVimInTerminal('-S XRegister123', {}) + call term_sendkeys(buf, "\<c-g>") + call WaitForAssert({-> assert_match('XREGISTER', term_getline(buf, 19))}) + call StopVimInTerminal(buf) +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index 2dfd4c83e..07bede551 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1143, /**/ 1142, /**/ -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1tmHRO-008pVn-GG%40256bit.org.