summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <bram@vim.org>2010-05-28 21:31:58 +0200
committerBram Moolenaar <bram@vim.org>2010-05-28 21:31:58 +0200
commit20bdb6c898f35a496e74dbb5d9c6aaa7dda645c2 (patch)
treecfab315e7a00a883fe220d271add3de9f724317c
parentbc49ceb2f844080449634d9388b1e594a0fbeadb (diff)
downloadvim-20bdb6c898f35a496e74dbb5d9c6aaa7dda645c2.tar.gz
updated for version 7.2.439v7.2.439
Problem: Invalid memory access when doing thesaurus completion and 'infercase' is set. Solution: Use the minimal length of completed word and replacement. (Dominique Pelle)
-rw-r--r--src/edit.c12
-rw-r--r--src/version.c2
2 files changed, 11 insertions, 3 deletions
diff --git a/src/edit.c b/src/edit.c
index 33e580f1..a84f32ee 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -2164,6 +2164,7 @@ ins_compl_add_infercase(str, len, icase, fname, dir, flags)
int i, c;
int actual_len; /* Take multi-byte characters */
int actual_compl_length; /* into account. */
+ int min_len;
int *wca; /* Wide character array. */
int has_lower = FALSE;
int was_letter = FALSE;
@@ -2204,6 +2205,11 @@ ins_compl_add_infercase(str, len, icase, fname, dir, flags)
#endif
actual_compl_length = compl_length;
+ /* "actual_len" may be smaller than "actual_compl_length" when using
+ * thesaurus, only use the minimum when comparing. */
+ min_len = actual_len < actual_compl_length
+ ? actual_len : actual_compl_length;
+
/* Allocate wide character array for the completion and fill it. */
wca = (int *)alloc((unsigned)(actual_len * sizeof(int)));
if (wca != NULL)
@@ -2219,7 +2225,7 @@ ins_compl_add_infercase(str, len, icase, fname, dir, flags)
/* Rule 1: Were any chars converted to lower? */
p = compl_orig_text;
- for (i = 0; i < actual_compl_length; ++i)
+ for (i = 0; i < min_len; ++i)
{
#ifdef FEAT_MBYTE
if (has_mbyte)
@@ -2247,7 +2253,7 @@ ins_compl_add_infercase(str, len, icase, fname, dir, flags)
if (!has_lower)
{
p = compl_orig_text;
- for (i = 0; i < actual_compl_length; ++i)
+ for (i = 0; i < min_len; ++i)
{
#ifdef FEAT_MBYTE
if (has_mbyte)
@@ -2268,7 +2274,7 @@ ins_compl_add_infercase(str, len, icase, fname, dir, flags)
/* Copy the original case of the part we typed. */
p = compl_orig_text;
- for (i = 0; i < actual_compl_length; ++i)
+ for (i = 0; i < min_len; ++i)
{
#ifdef FEAT_MBYTE
if (has_mbyte)
diff --git a/src/version.c b/src/version.c
index 31a49be3..f2a5992d 100644
--- a/src/version.c
+++ b/src/version.c
@@ -682,6 +682,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 439,
+/**/
438,
/**/
437,