From: Bram Moolenaar Date: Mon, 10 Apr 2017 20:22:42 +0000 (+0200) Subject: patch 8.0.0561: undefined behavior when using backslash after empty line X-Git-Tag: v8.0.0561 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=478af67dd6a9adc456464c3736bda328ae3a28cb;p=vim patch 8.0.0561: undefined behavior when using backslash after empty line Problem: Undefined behavior when using backslash after empty line. Solution: Check for an empty line. (Dominique Pelle, closes #1631) --- diff --git a/src/misc2.c b/src/misc2.c index 2f9fed57a..fa06e4740 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -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) diff --git a/src/testdir/test_vimscript.vim b/src/testdir/test_vimscript.vim index a299581e8..ce28e82c6 100644 --- a/src/testdir/test_vimscript.vim +++ b/src/testdir/test_vimscript.vim @@ -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 diff --git a/src/version.c b/src/version.c index 325be558f..91ef1f359 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 561, /**/ 560, /**/