]> granicus.if.org Git - vim/commitdiff
patch 9.0.0552: crash when using NUL in buffer that uses :source v9.0.0552
authorBram Moolenaar <Bram@vim.org>
Thu, 22 Sep 2022 20:35:19 +0000 (21:35 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 22 Sep 2022 20:35:19 +0000 (21:35 +0100)
Problem:    Crash when using NUL in buffer that uses :source.
Solution:   Don't get a next line when skipping over NL.

src/eval.c
src/testdir/test_source.vim
src/version.c

index 1f439701ed6c837daa043a6a786969156683734a..77f0d7fb3cbd35eb65489cdbe3b9366fbe9e2a38 100644 (file)
@@ -253,7 +253,7 @@ eval_expr_typval(typval_T *expr, typval_T *argv, int argc, typval_T *rettv)
            if (fc == NULL)
                return FAIL;
 
-           // Shortcut to call a compiled function without overhead.
+           // Shortcut to call a compiled function with minimal overhead.
            r = call_def_function(partial->pt_func, argc, argv,
                                          DEF_USE_PT_ARGV, partial, fc, rettv);
            remove_funccal();
@@ -2291,7 +2291,7 @@ eval_next_non_blank(char_u *arg, evalarg_T *evalarg, int *getnext)
 
        if (next != NULL)
        {
-           *getnext = TRUE;
+           *getnext = *p != NL;
            return skipwhite(next);
        }
     }
index 44cd2fdc72dbe6b017eec4fa1202341397f3ae01..2becf0817e3fa9309f86fdee5576bab02ddcf944 100644 (file)
@@ -665,5 +665,22 @@ func Test_source_buffer_long_line()
   call delete('Xtest.vim')
 endfunc
 
+func Test_source_buffer_with_NUL_char()
+  " This was trying to use a line below the buffer.
+  let lines =<< trim END
+      if !exists('g:loaded')
+        let g:loaded = 1
+        source
+      endif
+  END
+  " Can't have a NL in heredoc
+  let lines += ["silent! vim9 echo [0 \<NL> ? 'a' : 'b']"]
+  call writefile(lines, 'XsourceNul', '')
+  edit XsourceNul
+  source
+
+  bwipe!
+endfunc
+
 
 " vim: shiftwidth=2 sts=2 expandtab
index c3b6c12903a507f0e9569cd05c6aa5b03b8ebbb6..505185da500da0891508237d2685897b4b0b5388 100644 (file)
@@ -699,6 +699,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    552,
 /**/
     551,
 /**/