Skip to content

Commit 478af67

Browse files
committed
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)
1 parent 451a4a1 commit 478af67

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/misc2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2129,7 +2129,7 @@ ga_concat(garray_T *gap, char_u *s)
21292129
{
21302130
int len;
21312131

2132-
if (s == NULL)
2132+
if (s == NULL || *s == NUL)
21332133
return;
21342134
len = (int)STRLEN(s);
21352135
if (ga_grow(gap, len) == OK)

src/testdir/test_vimscript.vim

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,6 +1309,17 @@ func Test_script_lines()
13091309
endtry
13101310
endfunc
13111311

1312+
"-------------------------------------------------------------------------------
1313+
" Test 96: line continuation {{{1
1314+
"
1315+
" Undefined behavior was detected by ubsan with line continuation
1316+
" after an empty line.
1317+
"-------------------------------------------------------------------------------
1318+
func Test_script_emty_line_continuation()
1319+
1320+
\
1321+
endfunc
1322+
13121323
"-------------------------------------------------------------------------------
13131324
" Modelines {{{1
13141325
" vim: ts=8 sw=4 tw=80 fdm=marker

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
561,
767769
/**/
768770
560,
769771
/**/

0 commit comments

Comments
 (0)