diff options
author | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-08-08 23:16:36 -0400 |
---|---|---|
committer | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-08-09 00:44:06 -0400 |
commit | a44588798564dae1dc28b31af49e38399888d9a2 (patch) | |
tree | e18ae04a97fe45abe5629c3289d5910fb4b6c47a /src | |
parent | fe6cf2812b819297602ce355f8cfea157d64e110 (diff) | |
download | rneovim-a44588798564dae1dc28b31af49e38399888d9a2.tar.gz rneovim-a44588798564dae1dc28b31af49e38399888d9a2.tar.bz2 rneovim-a44588798564dae1dc28b31af49e38399888d9a2.zip |
vim-patch:8.0.1410: hang when using count() with an empty string
Problem: Hang when using count() with an empty string.
Solution: Return zero for an empty string. (Dominique Pelle, closes vim/vim#2465)
https://github.com/vim/vim/commit/338e47fdfdf0d918dae50a5cbf0cf4f7be45b4f0
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval.c | 2 | ||||
-rw-r--r-- | src/nvim/testdir/test_functions.vim | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index d9765af1dc..8db48062e9 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -7603,7 +7603,7 @@ static void f_count(typval_T *argvars, typval_T *rettv, FunPtr fptr) const char_u *expr = (char_u *)tv_get_string_chk(&argvars[1]); const char_u *p = argvars[0].vval.v_string; - if (!error && expr != NULL && p != NULL) { + if (!error && expr != NULL && *expr != NUL && p != NULL) { if (ic) { const size_t len = STRLEN(expr); diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index 285c4e6327..63794a7a85 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -723,6 +723,7 @@ func Test_count() call assert_equal(0, count("foo", "O")) call assert_equal(2, count("foo", "O", 1)) call assert_equal(2, count("fooooo", "oo")) + call assert_equal(0, count("foo", "")) endfunc func Test_changenr() |