summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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