Mercurial > vim
changeset 7062:6deb9d802fe4 v7.4.843
commit https://github.com/vim/vim/commit/d43f0951bca162d4491d57df9277b5dbc462944f
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Aug 27 22:30:47 2015 +0200
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)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 27 Aug 2015 22:45:03 +0200 |
parents | 5c01a7ba3f46 |
children | 91d434c99f2d |
files | src/misc2.c src/version.c |
diffstat | 2 files changed, 9 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/misc2.c +++ b/src/misc2.c @@ -5059,6 +5059,8 @@ ff_wc_equal(s1, s2) char_u *s2; { int i, j; + int c1 = NUL; + int c2 = NUL; int prev1 = NUL; int prev2 = NUL; @@ -5068,21 +5070,21 @@ ff_wc_equal(s1, s2) if (s1 == NULL || s2 == NULL) return FALSE; - for (i = 0, j = 0; s1[i] != NUL;) + for (i = 0, j = 0; s1[i] != NUL && s2[j] != NUL;) { - int c1 = PTR2CHAR(s1 + i); - int c2 = PTR2CHAR(s2 + j); + c1 = PTR2CHAR(s1 + i); + c2 = PTR2CHAR(s2 + j); if ((p_fic ? MB_TOLOWER(c1) != MB_TOLOWER(c2) : c1 != c2) && (prev1 != '*' || prev2 != '*')) - return FAIL; + return FALSE; prev2 = prev1; prev1 = c1; i += MB_PTR2LEN(s1 + i); j += MB_PTR2LEN(s2 + j); } - return TRUE; + return c1 == c2; } #endif