diff options
author | Jurica Bradaric <jbradaric@gmail.com> | 2016-02-09 22:59:16 +0100 |
---|---|---|
committer | Jurica Bradaric <jbradaric@gmail.com> | 2016-02-09 23:08:24 +0100 |
commit | c9898e0ec3c6e1eccf816536b780c5da6c047c2a (patch) | |
tree | f31c5caf39ada2277703c1f5313798d69c6b43b1 /src/nvim/file_search.c | |
parent | ab8a771dbd1fd4bf0a3ed0c90c0b7bec040c4c7a (diff) | |
download | rneovim-c9898e0ec3c6e1eccf816536b780c5da6c047c2a.tar.gz rneovim-c9898e0ec3c6e1eccf816536b780c5da6c047c2a.tar.bz2 rneovim-c9898e0ec3c6e1eccf816536b780c5da6c047c2a.zip |
vim-patch:7.4.843
Problem: Still possible to go beyond the end of a string.
Solution: Check for NUL also in second string. (Dominique Pelle)
https://github.com/vim/vim/commit/d43f0951bca162d4491d57df9277b5dbc462944f
Diffstat (limited to 'src/nvim/file_search.c')
-rw-r--r-- | src/nvim/file_search.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c index a421c555c1..7b1ad85faa 100644 --- a/src/nvim/file_search.c +++ b/src/nvim/file_search.c @@ -1057,6 +1057,8 @@ static ff_visited_list_hdr_T *ff_get_visited_list(char_u *filename, ff_visited_l */ static int ff_wc_equal(char_u *s1, char_u *s2) { + int c1 = NUL; + int c2 = NUL; int prev1 = NUL; int prev2 = NUL; @@ -1066,13 +1068,13 @@ static int ff_wc_equal(char_u *s1, char_u *s2) if (s1 == NULL || s2 == NULL) return FALSE; - for (int i = 0, j = 0; s1[i] != NUL;) { - int c1 = PTR2CHAR(s1 + i); - int c2 = PTR2CHAR(s2 + j); + for (int i = 0, j = 0; s1[i] != NUL && s2[j] != NUL;) { + c1 = PTR2CHAR(s1 + i); + c2 = PTR2CHAR(s2 + j); if ((p_fic ? vim_tolower(c1) != vim_tolower(c2) : c1 != c2) && (prev1 != '*' || prev2 != '*')) { - return FAIL; + return false; } prev2 = prev1; prev1 = c1; @@ -1080,7 +1082,7 @@ static int ff_wc_equal(char_u *s1, char_u *s2) i += MB_PTR2LEN(s1 + i); j += MB_PTR2LEN(s2 + j); } - return TRUE; + return c1 == c2; } /* |