Fix a crasher found by libFuzzer

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@245849 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/regex b/include/regex
index b355bbb..b2b556e 100644
--- a/include/regex
+++ b/include/regex
@@ -1733,6 +1733,8 @@
 void
 __back_ref<_CharT>::__exec(__state& __s) const
 {
+    if (__mexp_ > __s.__sub_matches_.size())
+        __throw_regex_error<regex_constants::error_backref>();
     sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_-1];
     if (__sm.matched)
     {