]> granicus.if.org Git - vim/commitdiff
patch 8.0.0561: undefined behavior when using backslash after empty line v8.0.0561
authorBram Moolenaar <Bram@vim.org>
Mon, 10 Apr 2017 20:22:42 +0000 (22:22 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 10 Apr 2017 20:22:42 +0000 (22:22 +0200)
Problem:    Undefined behavior when using backslash after empty line.
Solution:   Check for an empty line. (Dominique Pelle, closes #1631)

src/misc2.c
src/testdir/test_vimscript.vim
src/version.c

index 2f9fed57a41c7abe9facc920ef57cc98f4266c30..fa06e47401016aa9a85f487cf15239dd25524dbb 100644 (file)
@@ -2129,7 +2129,7 @@ ga_concat(garray_T *gap, char_u *s)
 {
     int    len;
 
-    if (s == NULL)
+    if (s == NULL || *s == NUL)
        return;
     len = (int)STRLEN(s);
     if (ga_grow(gap, len) == OK)
index a299581e88391b5f2948f593615130f8baef777c..ce28e82c648d0338cbfe084be3e75d24f4049c66 100644 (file)
@@ -1309,6 +1309,17 @@ func Test_script_lines()
     endtry
 endfunc
 
+"-------------------------------------------------------------------------------
+" Test 96:  line continuation                                              {{{1
+"
+"           Undefined behavior was detected by ubsan with line continuation
+"           after an empty line.
+"-------------------------------------------------------------------------------
+func Test_script_emty_line_continuation()
+
+    \
+endfunc
+
 "-------------------------------------------------------------------------------
 " Modelines                                                                {{{1
 " vim: ts=8 sw=4 tw=80 fdm=marker
index 325be558f31417222650cb706f62214dc9a42f9a..91ef1f359f5074f4383a41e1c5c0ae6645d5ae01 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    561,
 /**/
     560,
 /**/