From f42ef3efcad9095920232a0a710a80c5c4720170 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Wed, 3 Feb 2016 19:30:20 +0000 Subject: re.results.form: Format out-of-range subexpression references as null Rather than crashing in match_results::format() when a reference to a marked subexpression is out of range, format the subexpression as empty (i.e., replace it with an empty string). Note that match_results::operator[]() has a range-check and returns a null match in this case, so this just re-uses that logic. llvm-svn: 259682 --- libcxx/include/regex | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'libcxx/include/regex') diff --git a/libcxx/include/regex b/libcxx/include/regex index ca455f0ceea..f1f3264d320 100644 --- a/libcxx/include/regex +++ b/libcxx/include/regex @@ -5387,8 +5387,8 @@ match_results<_BidirectionalIterator, _Allocator>::format(_OutputIter __out, if ('0' <= *__fmt_first && *__fmt_first <= '9') { size_t __i = *__fmt_first - '0'; - __out = _VSTD::copy(__matches_[__i].first, - __matches_[__i].second, __out); + __out = _VSTD::copy((*this)[__i].first, + (*this)[__i].second, __out); } else { @@ -5439,8 +5439,8 @@ match_results<_BidirectionalIterator, _Allocator>::format(_OutputIter __out, ++__fmt_first; __i = 10 * __i + *__fmt_first - '0'; } - __out = _VSTD::copy(__matches_[__i].first, - __matches_[__i].second, __out); + __out = _VSTD::copy((*this)[__i].first, + (*this)[__i].second, __out); } else { -- cgit v1.2.3