From 901c8fbcdb113173dd7e11adf35d193f6d4b3986 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Fri, 12 May 2017 11:41:35 -0400 Subject: regexp_nfa: Fix invalid fallthrough in character class detection When the end character in a range matches a different standard range (e.g., [0-z]), the range would be incorrectly detected as the class of the end character (CLASS_az). Instead of using a fallthrough, immediately FAIL when the end character doesn't match the expected range. --- src/nvim/regexp_nfa.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index 149dca43e6..24c156d2ba 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -634,6 +634,7 @@ static int nfa_recognize_char_class(char_u *start, char_u *end, int extra_newl) config |= CLASS_o7; break; } + return FAIL; case 'a': if (*(p + 2) == 'z') { config |= CLASS_az; @@ -642,6 +643,7 @@ static int nfa_recognize_char_class(char_u *start, char_u *end, int extra_newl) config |= CLASS_af; break; } + return FAIL; case 'A': if (*(p + 2) == 'Z') { config |= CLASS_AZ; @@ -650,7 +652,7 @@ static int nfa_recognize_char_class(char_u *start, char_u *end, int extra_newl) config |= CLASS_AF; break; } - /* FALLTHROUGH */ + return FAIL; default: return FAIL; } -- cgit