changeset 4464:c83656c9745a v7.3.980

updated for version 7.3.980 Problem: Regexp logs may contain garbage. Character classes don't work correctly for multi-byte characters. Solution: Check for end of post list. Only use "is" functions for characters up to 255. (Ken Takata)
author Bram Moolenaar <bram@vim.org>
date Mon, 20 May 2013 22:20:02 +0200
parents 6ff2a37ec138
children bf405e5aabf6
files src/regexp_nfa.c src/version.c
diffstat 2 files changed, 9 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/regexp_nfa.c
+++ b/src/regexp_nfa.c
@@ -1826,13 +1826,13 @@ nfa_postfix_dump(expr, retval)
 	else if (retval == OK)
 	    fprintf(f, ">>> NFA engine succeeded !\n");
 	fprintf(f, "Regexp: \"%s\"\nPostfix notation (char): \"", expr);
-	for (p=post_start; *p; p++)
+	for (p = post_start; *p && p < post_end; p++)
 	{
 	    nfa_set_code(*p);
 	    fprintf(f, "%s, ", code);
 	}
 	fprintf(f, "\"\nPostfix notation (int): ");
-	for (p=post_start; *p; p++)
+	for (p = post_start; *p && p < post_end; p++)
 		fprintf(f, "%d ", *p);
 	fprintf(f, "\n\n");
 	fclose(f);
@@ -2667,11 +2667,11 @@ check_char_class(class, c)
     switch (class)
     {
 	case NFA_CLASS_ALNUM:
-	    if (isalnum(c))
+	    if (c >= 1 && c <= 255 && isalnum(c))
 		return OK;
 	    break;
 	case NFA_CLASS_ALPHA:
-	    if (isalpha(c))
+	    if (c >= 1 && c <= 255 && isalpha(c))
 		return OK;
 	    break;
 	case NFA_CLASS_BLANK:
@@ -2679,7 +2679,7 @@ check_char_class(class, c)
 		return OK;
 	    break;
 	case NFA_CLASS_CNTRL:
-	    if (iscntrl(c))
+	    if (c >= 1 && c <= 255 && iscntrl(c))
 		return OK;
 	    break;
 	case NFA_CLASS_DIGIT:
@@ -2687,7 +2687,7 @@ check_char_class(class, c)
 		return OK;
 	    break;
 	case NFA_CLASS_GRAPH:
-	    if (isgraph(c))
+	    if (c >= 1 && c <= 255 && isgraph(c))
 		return OK;
 	    break;
 	case NFA_CLASS_LOWER:
@@ -2699,7 +2699,7 @@ check_char_class(class, c)
 		return OK;
 	    break;
 	case NFA_CLASS_PUNCT:
-	    if (ispunct(c))
+	    if (c >= 1 && c <= 255 && ispunct(c))
 		return OK;
 	    break;
 	case NFA_CLASS_SPACE:
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    980,
+/**/
     979,
 /**/
     978,