# HG changeset patch # User Bram Moolenaar # Date 1663879504 -7200 # Node ID 36f1b763ae1677a3b193efa23baa9981e12dc3e3 # Parent 8b800cb5fb8b446ab89ec699ab0d0a0856f373e1 patch 9.0.0552: crash when using NUL in buffer that uses :source Commit: https://github.com/vim/vim/commit/69082916c8b5d321545d60b9f5facad0a2dd5a4e Author: Bram Moolenaar Date: Thu Sep 22 21:35:19 2022 +0100 patch 9.0.0552: crash when using NUL in buffer that uses :source Problem: Crash when using NUL in buffer that uses :source. Solution: Don't get a next line when skipping over NL. diff --git a/src/eval.c b/src/eval.c --- a/src/eval.c +++ b/src/eval.c @@ -253,7 +253,7 @@ eval_expr_typval(typval_T *expr, typval_ 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 if (next != NULL) { - *getnext = TRUE; + *getnext = *p != NL; return skipwhite(next); } } diff --git a/src/testdir/test_source.vim b/src/testdir/test_source.vim --- a/src/testdir/test_source.vim +++ b/src/testdir/test_source.vim @@ -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 \ ? 'a' : 'b']"] + call writefile(lines, 'XsourceNul', '') + edit XsourceNul + source + + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -700,6 +700,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 552, +/**/ 551, /**/ 550,