changeset 2618:fb60c9f35517 v7.3.040

updated for version 7.3.040 Problem: Comparing strings while ignoring case goes beyond end of the string when there are illegal bytes. (Dominique Pelle) Solution: Explicitly check for illegal bytes.
author Bram Moolenaar <bram@vim.org>
date Wed, 27 Oct 2010 13:37:44 +0200
parents f2927225367a
children 6a80537ac7aa
files src/mbyte.c src/version.c
diffstat 2 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/mbyte.c
+++ b/src/mbyte.c
@@ -3124,6 +3124,9 @@ mb_strnicmp(s1, s2, nn)
 		/* If one of the two characters is incomplete return -1. */
 		if (incomplete || i + utf_byte2len(s2[i]) > n)
 		    return -1;
+		/* Don't case-fold illegal bytes or truncated characters. */
+		if (utf_ptr2len(s1 + i) < l || utf_ptr2len(s2 + i) < l)
+		    return -1;
 		cdiff = utf_fold(utf_ptr2char(s1 + i))
 					     - utf_fold(utf_ptr2char(s2 + i));
 		if (cdiff != 0)
--- 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 */
 /**/
+    40,
+/**/
     39,
 /**/
     38,