]> granicus.if.org Git - vim/commitdiff
patch 8.2.1910: reading past the end of the command line v8.2.1910
authorBram Moolenaar <Bram@vim.org>
Mon, 26 Oct 2020 20:39:13 +0000 (21:39 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 26 Oct 2020 20:39:13 +0000 (21:39 +0100)
Problem:    Reading past the end of the command line.
Solution:   Check for NUL. (closes #7204)

src/ex_docmd.c
src/testdir/test_edit.vim
src/version.c

index 5e9eeb78fec89ed1cfad9b7be0b799a8fbedf5a6..97d4b421da122aeb8e41e4f0c45ab53df4c36807 100644 (file)
@@ -2958,8 +2958,7 @@ undo_cmdmod(cmdmod_T *cmod)
        cmod->cmod_save_ei = NULL;
     }
 
-    if (cmod->cmod_filter_regmatch.regprog != NULL)
-       vim_regfree(cmod->cmod_filter_regmatch.regprog);
+    vim_regfree(cmod->cmod_filter_regmatch.regprog);
 
     if (cmod->cmod_save_msg_silent > 0)
     {
@@ -4696,6 +4695,8 @@ separate_nextcmd(exarg_T *eap)
        {
            p += 2;
            (void)skip_expr(&p, NULL);
+           if (*p == NUL)              // stop at NUL after CTRL-V
+               break;
        }
 #endif
 
index 6a84b1c8c6b331b0fe0ec01429ffc656f0378984..de3e3a161232e96b2992325efd762a06bf2f5793 100644 (file)
@@ -1832,4 +1832,11 @@ func Test_edit_browse()
   bwipe!
 endfunc
 
+func Test_read_invalid()
+  set encoding=latin1
+  " This was not properly checking for going past the end.
+  call assert_fails('r`=', 'E484')
+  set encoding=utf-8
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index ac8155a13bdcad7d309ab41d994c6b6a5ff55dd9..04bfc7db83ea2747922dbd72dc307212430823d9 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1910,
 /**/
     1909,
 /**/