summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <bram@vim.org>2011-12-08 15:09:52 +0100
committerBram Moolenaar <bram@vim.org>2011-12-08 15:09:52 +0100
commit3346c1a434b42707f855a059fc77c3bf30aaf03a (patch)
tree96940de93992ce7490021a24d14d0ded82c0fa4f
parentbdf01dc69e46e29b610792a1b9842970bd057093 (diff)
downloadvim-3346c1a434b42707f855a059fc77c3bf30aaf03a.tar.gz
updated for version 7.3.365v7.3.365v7-3-365
Problem: Crash when using a large Unicode character in a file that has syntax highlighting. (ngollan) Solution: Check for going past the end of the utf tables. (Dominique Pelle)
-rw-r--r--src/mbyte.c15
-rw-r--r--src/version.c2
2 files changed, 11 insertions, 6 deletions
diff --git a/src/mbyte.c b/src/mbyte.c
index da97b346..2a202f34 100644
--- a/src/mbyte.c
+++ b/src/mbyte.c
@@ -2764,19 +2764,22 @@ utf_convert(a, table, tableSize)
int tableSize;
{
int start, mid, end; /* indices into table */
+ int entries = tableSize / sizeof(convertStruct);
start = 0;
- end = tableSize / sizeof(convertStruct);
+ end = entries;
while (start < end)
{
/* need to search further */
- mid = (end + start) /2;
+ mid = (end + start) / 2;
if (table[mid].rangeEnd < a)
start = mid + 1;
else
end = mid;
}
- if (table[start].rangeStart <= a && a <= table[start].rangeEnd
+ if (start < entries
+ && table[start].rangeStart <= a
+ && a <= table[start].rangeEnd
&& (a - table[start].rangeStart) % table[start].step == 0)
return (a + table[start].offset);
else
@@ -2791,7 +2794,7 @@ utf_convert(a, table, tableSize)
utf_fold(a)
int a;
{
- return utf_convert(a, foldCase, sizeof(foldCase));
+ return utf_convert(a, foldCase, (int)sizeof(foldCase));
}
static convertStruct toLower[] =
@@ -3119,7 +3122,7 @@ utf_toupper(a)
return TOUPPER_LOC(a);
/* For any other characters use the above mapping table. */
- return utf_convert(a, toUpper, sizeof(toUpper));
+ return utf_convert(a, toUpper, (int)sizeof(toUpper));
}
int
@@ -3152,7 +3155,7 @@ utf_tolower(a)
return TOLOWER_LOC(a);
/* For any other characters use the above mapping table. */
- return utf_convert(a, toLower, sizeof(toLower));
+ return utf_convert(a, toLower, (int)sizeof(toLower));
}
int
diff --git a/src/version.c b/src/version.c
index 6e30bf95..3cb21950 100644
--- a/src/version.c
+++ b/src/version.c
@@ -715,6 +715,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 365,
+/**/
364,
/**/
363,