summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2016-01-19 00:50:37 +0000
committerMarshall Clow <mclow.lists@gmail.com>2016-01-19 00:50:37 +0000
commitb414b2f54b0acaddefdb4a36ec19e01394cec180 (patch)
tree8048d1fc5beca61c2d2caa3ac3cbecb7090ce087
parent848da137186c745e105b4937e68cc5d6edd2d30c (diff)
downloadbcm5719-llvm-b414b2f54b0acaddefdb4a36ec19e01394cec180.tar.gz
bcm5719-llvm-b414b2f54b0acaddefdb4a36ec19e01394cec180.zip
Fix PR#26175. Thanks to Josh Petrie for the report and the patch. Reviewed as http://reviews.llvm.org/D16262
llvm-svn: 258107
-rw-r--r--libcxx/include/regex3
-rw-r--r--libcxx/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp1
2 files changed, 4 insertions, 0 deletions
diff --git a/libcxx/include/regex b/libcxx/include/regex
index b9dac4765cd..ca455f0ceea 100644
--- a/libcxx/include/regex
+++ b/libcxx/include/regex
@@ -4265,6 +4265,9 @@ basic_regex<_CharT, _Traits>::__parse_atom_escape(_ForwardIterator __first,
if (__first != __last && *__first == '\\')
{
_ForwardIterator __t1 = _VSTD::next(__first);
+ if (__t1 == __last)
+ __throw_regex_error<regex_constants::error_escape>();
+
_ForwardIterator __t2 = __parse_decimal_escape(__t1, __last);
if (__t2 != __t1)
__first = __t2;
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
index 4da4d957a88..9459cd74ccf 100644
--- a/libcxx/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
@@ -33,6 +33,7 @@ int main()
{
assert(error_escape_thrown("[\\a]"));
assert(error_escape_thrown("\\a"));
+ assert(error_escape_thrown("\\"));
assert(error_escape_thrown("[\\e]"));
assert(error_escape_thrown("\\e"));
OpenPOWER on IntegriCloud