0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

updated for version 7.3.521

Problem:    Using "z=" on a multi-byte character may cause a crash.
Solution:   Don't use strlen() on an int pointer.
This commit is contained in:
Bram Moolenaar 2012-05-18 18:08:01 +02:00
parent 2969570036
commit f9de140e7f
2 changed files with 10 additions and 6 deletions

View File

@ -14494,13 +14494,15 @@ spell_soundfold_wsal(slang, inword, res)
int p0 = -333; int p0 = -333;
int c0; int c0;
int did_white = FALSE; int did_white = FALSE;
int wordlen;
/* /*
* Convert the multi-byte string to a wide-character string. * Convert the multi-byte string to a wide-character string.
* Remove accents, if wanted. We actually remove all non-word characters. * Remove accents, if wanted. We actually remove all non-word characters.
* But keep white space. * But keep white space.
*/ */
n = 0; wordlen = 0;
for (s = inword; *s != NUL; ) for (s = inword; *s != NUL; )
{ {
t = s; t = s;
@ -14521,12 +14523,12 @@ spell_soundfold_wsal(slang, inword, res)
continue; continue;
} }
} }
word[n++] = c; word[wordlen++] = c;
} }
word[n] = NUL; word[wordlen] = NUL;
/* /*
* This comes from Aspell phonet.cpp. * This algorithm comes from Aspell phonet.cpp.
* Converted from C++ to C. Added support for multi-byte chars. * Converted from C++ to C. Added support for multi-byte chars.
* Changed to keep spaces. * Changed to keep spaces.
*/ */
@ -14711,7 +14713,7 @@ spell_soundfold_wsal(slang, inword, res)
} }
if (k > k0) if (k > k0)
mch_memmove(word + i + k0, word + i + k, mch_memmove(word + i + k0, word + i + k,
sizeof(int) * (STRLEN(word + i + k) + 1)); sizeof(int) * (wordlen - (i + k) + 1));
/* new "actual letter" */ /* new "actual letter" */
c = word[i]; c = word[i];
@ -14739,7 +14741,7 @@ spell_soundfold_wsal(slang, inword, res)
if (c != NUL) if (c != NUL)
wres[reslen++] = c; wres[reslen++] = c;
mch_memmove(word, word + i + 1, mch_memmove(word, word + i + 1,
sizeof(int) * (STRLEN(word + i + 1) + 1)); sizeof(int) * (wordlen - (i + 1) + 1));
i = 0; i = 0;
z0 = 1; z0 = 1;
} }

View File

@ -714,6 +714,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
521,
/**/ /**/
520, 520,
/**/ /**/