To: vim_dev@googlegroups.com Subject: Patch 8.2.4009 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4009 Problem: Reading one byte beyond the end of the line. Solution: Check for NUL byte first. Files: src/vim9compile.c, src/ex_docmd.c, src/testdir/test_vim9_func.vim *** ../vim-8.2.4008/src/vim9compile.c 2022-01-04 15:54:34.592486131 +0000 --- src/vim9compile.c 2022-01-05 16:39:44.058685384 +0000 *************** *** 2781,2787 **** cmd = ea.cmd; if ((*cmd != '$' || starts_with_colon) && (starts_with_colon || !(*cmd == '\'' ! || (cmd[0] == cmd[1] && (*cmd == '+' || *cmd == '-'))))) { ea.cmd = skip_range(ea.cmd, TRUE, NULL); if (ea.cmd > cmd) --- 2781,2788 ---- cmd = ea.cmd; if ((*cmd != '$' || starts_with_colon) && (starts_with_colon || !(*cmd == '\'' ! || (cmd[0] != NUL && cmd[0] == cmd[1] ! && (*cmd == '+' || *cmd == '-'))))) { ea.cmd = skip_range(ea.cmd, TRUE, NULL); if (ea.cmd > cmd) *** ../vim-8.2.4008/src/ex_docmd.c 2022-01-05 16:08:59.520426444 +0000 --- src/ex_docmd.c 2022-01-05 16:40:43.118546827 +0000 *************** *** 3632,3638 **** } // Check for "++nr" and "--nr". ! if (p == eap->cmd && p[0] == p[1] && (*p == '+' || *p == '-')) { eap->cmdidx = *p == '+' ? CMD_increment : CMD_decrement; return eap->cmd + 2; --- 3632,3639 ---- } // Check for "++nr" and "--nr". ! if (p == eap->cmd && p[0] != NUL && p[0] == p[1] ! && (*p == '+' || *p == '-')) { eap->cmdidx = *p == '+' ? CMD_increment : CMD_decrement; return eap->cmd + 2; *** ../vim-8.2.4008/src/testdir/test_vim9_func.vim 2022-01-03 12:27:59.359039951 +0000 --- src/testdir/test_vim9_func.vim 2022-01-05 16:38:51.350809594 +0000 *************** *** 3537,3542 **** --- 3537,3553 ---- unlet g:mydict enddef + def Test_go_beyond_end_of_cmd() + # this was reading the byte after the end of the line + var lines =<< trim END + def F() + cal + enddef + defcompile + END + CheckScriptFailure(lines, 'E476:') + enddef + if has('python3') def Test_python3_heredoc() py3 << trim EOF *** ../vim-8.2.4008/src/version.c 2022-01-05 16:08:59.528426430 +0000 --- src/version.c 2022-01-05 16:42:57.250234304 +0000 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 4009, /**/ -- Get a life? What is the URL where it can be downloaded? /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///