From 7faf682525ab1274ed30f1a48336a89f53841136 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 12 Aug 2018 17:19:21 -0400 Subject: vim-patch:8.0.1227: undefined left shift in readfile() Problem: Undefined left shift in readfile(). (Brian 'geeknik' Carpenter) Solution: Add cast to unsigned. (Dominique Pelle, closes vim/vim#2253) https://github.com/vim/vim/commit/dc1c98129484e7879bc6dbf38e523beb730988b6 --- src/nvim/fileio.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 0858436db3..af02b7faf2 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -1380,15 +1380,15 @@ retry: } } else if (fio_flags & FIO_UCS4) { if (fio_flags & FIO_ENDIAN_L) { - u8c = (*--p << 24); - u8c += (*--p << 16); - u8c += (*--p << 8); + u8c = (unsigned)*--p << 24; + u8c += (unsigned)*--p << 16; + u8c += (unsigned)*--p << 8; u8c += *--p; } else { /* big endian */ u8c = *--p; - u8c += (*--p << 8); - u8c += (*--p << 16); - u8c += (*--p << 24); + u8c += (unsigned)*--p << 8; + u8c += (unsigned)*--p << 16; + u8c += (unsigned)*--p << 24; } } else { /* UTF-8 */ if (*--p < 0x80) -- cgit From 0b38011328020b5072201522a62dc1e8e39a42b3 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 12 Aug 2018 17:56:46 -0400 Subject: vim-patch:8.0.1243: no test for what 8.0.1227 fixes Problem: No test for what 8.0.1227 fixes. Solution: Add a test that triggers the problem. (Christian Brabandt) https://github.com/vim/vim/commit/f45938cc20ed6992e5215ffe41b73b528c78be9c --- src/nvim/testdir/test_normal.vim | 7 +++++++ src/nvim/testdir/test_search.vim | 15 +++++++++++++++ 2 files changed, 22 insertions(+) (limited to 'src') diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim index c638920dd3..4c63bd1f71 100644 --- a/src/nvim/testdir/test_normal.vim +++ b/src/nvim/testdir/test_normal.vim @@ -1201,6 +1201,13 @@ func! Test_normal19_z_spell() call assert_match("Word 'goood' added to ./Xspellfile2.add", a) call assert_equal('goood', cnt[0]) + " Test for :spellgood! + let temp = execute(':spe!0/0') + call assert_match('Invalid region', temp) + let spellfile = matchstr(temp, 'Invalid region nr in \zs.*\ze line \d: 0') + call assert_equal(['# goood', '# goood/!', '#oood', '0/0'], readfile(spellfile)) + call delete(spellfile) + " clean up exe "lang" oldlang call delete("./Xspellfile.add") diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim index 5da9397be5..50be1f83e6 100644 --- a/src/nvim/testdir/test_search.vim +++ b/src/nvim/testdir/test_search.vim @@ -453,3 +453,18 @@ func Test_search_multibyte() enew! let &encoding = save_enc endfunc + +func Test_search_undefined_behaviour() + if !has("terminal") + return + endif + let h = winheight(0) + if h < 3 + return + endif + " did cause an undefined left shift + let g:buf = term_start([GetVimProg(), '--clean', '-e', '-s', '-c', 'call search(getline("."))', 'samples/test000'], {'term_rows': 3}) + call assert_equal([''], getline(1, '$')) + call term_sendkeys(g:buf, ":qa!\") + bwipe! +endfunc -- cgit From 3fd2efdb26a50e252aa0c463ecd4f44755fbd744 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 12 Aug 2018 18:03:21 -0400 Subject: vim-patch:8.0.1257: no test for fix of undefined behavior Problem: No test for fix of undefined behavior. Solution: Add a test. (closes vim/vim#2255) https://github.com/vim/vim/commit/2973daafe1732963b8924cb9df53c608804d66b3 --- src/nvim/testdir/test_search.vim | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim index 50be1f83e6..42c56dced7 100644 --- a/src/nvim/testdir/test_search.vim +++ b/src/nvim/testdir/test_search.vim @@ -468,3 +468,7 @@ func Test_search_undefined_behaviour() call term_sendkeys(g:buf, ":qa!\") bwipe! endfunc + +func Test_search_undefined_behaviour2() + call search("\%UC0000000") +endfunc -- cgit From cfb2383c26847e9332d1283fa15753b09d322f2f Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 12 Aug 2018 18:06:17 -0400 Subject: vim-patch:8.0.1397: pattern with \& following nothing gives an error Problem: Pattern with \& following nothing gives an error. Solution: Emit an empty node when needed. https://github.com/vim/vim/commit/890dd05492d88d48eee1dda7f7a1811d027ce7ca --- src/nvim/regexp_nfa.c | 9 +++++---- src/nvim/testdir/test_search.vim | 8 ++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index 3b905f5efc..2536de27c1 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -2131,7 +2131,6 @@ static int nfa_regconcat(void) */ static int nfa_regbranch(void) { - int ch; int old_post_pos; old_post_pos = (int)(post_ptr - post_start); @@ -2140,10 +2139,13 @@ static int nfa_regbranch(void) if (nfa_regconcat() == FAIL) return FAIL; - ch = peekchr(); /* Try next concats */ - while (ch == Magic('&')) { + while (peekchr() == Magic('&')) { skipchr(); + // if concat is empty do emit a node + if (old_post_pos == (int)(post_ptr - post_start)) { + EMIT(NFA_EMPTY); + } EMIT(NFA_NOPEN); EMIT(NFA_PREV_ATOM_NO_WIDTH); old_post_pos = (int)(post_ptr - post_start); @@ -2153,7 +2155,6 @@ static int nfa_regbranch(void) if (old_post_pos == (int)(post_ptr - post_start)) EMIT(NFA_EMPTY); EMIT(NFA_CONCAT); - ch = peekchr(); } /* if a branch is empty, emit one node for it */ diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim index 42c56dced7..7663c9e283 100644 --- a/src/nvim/testdir/test_search.vim +++ b/src/nvim/testdir/test_search.vim @@ -472,3 +472,11 @@ endfunc func Test_search_undefined_behaviour2() call search("\%UC0000000") endfunc + +" This was causing E874. Also causes an invalid read? +func Test_look_behind() + new + call setline(1, '0\|\&\n\@<=') + call search(getline(".")) + bwipe! +endfunc -- cgit From a4c957bab7270e0631f147f572b8d905d9c7acda Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 12 Aug 2018 18:21:58 -0400 Subject: lint --- src/nvim/fileio.c | 12 ++++++------ src/nvim/regexp_nfa.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index af02b7faf2..78fac5acf8 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -1380,15 +1380,15 @@ retry: } } else if (fio_flags & FIO_UCS4) { if (fio_flags & FIO_ENDIAN_L) { - u8c = (unsigned)*--p << 24; - u8c += (unsigned)*--p << 16; - u8c += (unsigned)*--p << 8; + u8c = (unsigned)(*--p) << 24; + u8c += (unsigned)(*--p) << 16; + u8c += (unsigned)(*--p) << 8; u8c += *--p; } else { /* big endian */ u8c = *--p; - u8c += (unsigned)*--p << 8; - u8c += (unsigned)*--p << 16; - u8c += (unsigned)*--p << 24; + u8c += (unsigned)(*--p) << 8; + u8c += (unsigned)(*--p) << 16; + u8c += (unsigned)(*--p) << 24; } } else { /* UTF-8 */ if (*--p < 0x80) diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index 2536de27c1..29191c14a8 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -2139,7 +2139,7 @@ static int nfa_regbranch(void) if (nfa_regconcat() == FAIL) return FAIL; - /* Try next concats */ + // Try next concats while (peekchr() == Magic('&')) { skipchr(); // if concat is empty do emit a node -- cgit