]> granicus.if.org Git - vim/commitdiff
patch 8.2.3116: Vim9: crash when debugging a function with line continuation v8.2.3116
authorBram Moolenaar <Bram@vim.org>
Wed, 7 Jul 2021 18:10:43 +0000 (20:10 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 7 Jul 2021 18:10:43 +0000 (20:10 +0200)
Problem:    Vim9: crash when debugging a function with line continuation.
Solution:   Check for a NULL pointer. (closes #8521)

src/testdir/test_debugger.vim
src/version.c
src/vim9execute.c

index 97e115bf3ef30a48b4e196e581fd06a8af7d7d99..5b12c58778153ae4e3b10915faca29adf51487ae 100644 (file)
@@ -1009,6 +1009,7 @@ func Test_debug_def_function()
            eval 1
          enddef
     enddef
+
     def g:FuncComment()
       # comment
       echo "first"
@@ -1016,6 +1017,7 @@ func Test_debug_def_function()
       # comment
       echo "second"
     enddef
+
     def g:FuncForLoop()
       eval 1
       for i in [11, 22, 33]
@@ -1023,6 +1025,11 @@ func Test_debug_def_function()
       endfor
       echo "done"
     enddef
+
+    def g:FuncWithSplitLine()
+        eval 1
+           | eval 2
+    enddef
   END
   call writefile(file, 'Xtest.vim')
 
@@ -1078,6 +1085,12 @@ func Test_debug_def_function()
   call RunDbgCmd(buf, 'next', ['function FuncForLoop', 'line 2: for i in [11, 22, 33]'])
   call RunDbgCmd(buf, 'echo i', ['22'])
 
+  call RunDbgCmd(buf, 'breakdel *')
+  call RunDbgCmd(buf, 'cont')
+
+  call RunDbgCmd(buf, ':breakadd func FuncWithSplitLine')
+  call RunDbgCmd(buf, ':call FuncWithSplitLine()', ['function FuncWithSplitLine', 'line 1: eval 1 | eval 2'])
+
   call RunDbgCmd(buf, 'cont')
   call StopVimInTerminal(buf)
   call delete('Xtest.vim')
index e2f74e926cc4f7f96b1cd0ab8700599d4918fcb5..1deb3e4826738e67cf9216024a14a2f2b20abd8f 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3116,
 /**/
     3115,
 /**/
index b194e6a2a2e56ada5af39713219a86df31ceb998..87f3c424ea311d73bf29d898dbf0fea9b13d1d97 100644 (file)
@@ -1497,9 +1497,11 @@ handle_debug(isn_T *iptr, ectx_T *ectx)
        ga_init2(&ga, sizeof(char_u *), 10);
        for (lnum = iptr->isn_lnum; lnum < end_lnum; ++lnum)
        {
-           char_u *p = skipwhite(
-                              ((char_u **)ufunc->uf_lines.ga_data)[lnum - 1]);
+           char_u *p = ((char_u **)ufunc->uf_lines.ga_data)[lnum - 1];
 
+           if (p == NULL)
+               continue;  // left over from continuation line
+           p = skipwhite(p);
            if (*p == '#')
                break;
            if (ga_grow(&ga, 1) == OK)