diff options
author | Howard Hinnant <hhinnant@apple.com> | 2013-07-15 18:21:11 +0000 |
---|---|---|
committer | Howard Hinnant <hhinnant@apple.com> | 2013-07-15 18:21:11 +0000 |
commit | 22161401df1fe5f3eb57f099e8bca065822549df (patch) | |
tree | d4c85cedc0aa88fabafedc1085192ca7424da144 /libcxx/include/regex | |
parent | 10f8387b9430099bd5dc43db860ade8d165d8d94 (diff) | |
download | bcm5719-llvm-22161401df1fe5f3eb57f099e8bca065822549df.tar.gz bcm5719-llvm-22161401df1fe5f3eb57f099e8bca065822549df.zip |
Bill Fisher: This patch fixes an ill-formed comparison when parsing control escapes, e.g. "\cA\ca". The code will now throw an error_escape exception for invalid control sequences like "\c:" or "\c".
I've added the test cases to bad_escape.pass.cpp.
llvm-svn: 186335
Diffstat (limited to 'libcxx/include/regex')
-rw-r--r-- | libcxx/include/regex | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libcxx/include/regex b/libcxx/include/regex index 19e08b13aaf..3ec2ff92ee0 100644 --- a/libcxx/include/regex +++ b/libcxx/include/regex @@ -4418,7 +4418,8 @@ basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first, case 'c': if ((__t = _VSTD::next(__first)) != __last) { - if ('A' <= *__t <= 'Z' || 'a' <= *__t <= 'z') + if (('A' <= *__t && *__t <= 'Z') || + ('a' <= *__t && *__t <= 'z')) { if (__str) *__str = _CharT(*__t % 32); @@ -4426,7 +4427,15 @@ basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first, __push_char(_CharT(*__t % 32)); __first = ++__t; } +#ifndef _LIBCPP_NO_EXCEPTIONS + else + throw regex_error(regex_constants::error_escape); +#endif // _LIBCPP_NO_EXCEPTIONS } +#ifndef _LIBCPP_NO_EXCEPTIONS + else + throw regex_error(regex_constants::error_escape); +#endif // _LIBCPP_NO_EXCEPTIONS break; case 'u': ++__first; |