summaryrefslogtreecommitdiff
path: root/src/spell.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2012-05-18 18:08:01 +0200
committerBram Moolenaar <Bram@vim.org>2012-05-18 18:08:01 +0200
commitf9de140e7f45f4f79123519cb69c385e8e88105b (patch)
treeeeb613bd7b4e2ce67f0c774a136c54110f360352 /src/spell.c
parent2969570036e154c440cab5a4f8a2cead22587dd9 (diff)
downloadvim-git-f9de140e7f45f4f79123519cb69c385e8e88105b.tar.gz
updated for version 7.3.521v7.3.521
Problem: Using "z=" on a multi-byte character may cause a crash. Solution: Don't use strlen() on an int pointer.
Diffstat (limited to 'src/spell.c')
-rw-r--r--src/spell.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/spell.c b/src/spell.c
index f3d64e7c5..2ab31c92f 100644
--- a/src/spell.c
+++ b/src/spell.c
@@ -14494,13 +14494,15 @@ spell_soundfold_wsal(slang, inword, res)
int p0 = -333;
int c0;
int did_white = FALSE;
+ int wordlen;
+
/*
* Convert the multi-byte string to a wide-character string.
* Remove accents, if wanted. We actually remove all non-word characters.
* But keep white space.
*/
- n = 0;
+ wordlen = 0;
for (s = inword; *s != NUL; )
{
t = s;
@@ -14521,12 +14523,12 @@ spell_soundfold_wsal(slang, inword, res)
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.
* Changed to keep spaces.
*/
@@ -14711,7 +14713,7 @@ spell_soundfold_wsal(slang, inword, res)
}
if (k > k0)
mch_memmove(word + i + k0, word + i + k,
- sizeof(int) * (STRLEN(word + i + k) + 1));
+ sizeof(int) * (wordlen - (i + k) + 1));
/* new "actual letter" */
c = word[i];
@@ -14739,7 +14741,7 @@ spell_soundfold_wsal(slang, inword, res)
if (c != NUL)
wres[reslen++] = c;
mch_memmove(word, word + i + 1,
- sizeof(int) * (STRLEN(word + i + 1) + 1));
+ sizeof(int) * (wordlen - (i + 1) + 1));
i = 0;
z0 = 1;
}