From a9602d56de133730a3d8bc02bd317396000663f1 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Sat, 29 Jun 2013 23:45:43 +0000 Subject: [PATCH] Prevent '\b' from backing up into invalid memory. Fixes http://llvm.org/bugs/show_bug.cgi?id=16240. Sorry, I can not think of a good test case for this one, except by running valgrind as reported in the bug. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@185273 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/regex | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/include/regex b/include/regex index 52c9178a..02211672 100644 --- a/include/regex +++ b/include/regex @@ -2843,6 +2843,15 @@ private: const basic_regex<_Cp, _Tp>& __e, regex_constants::match_flag_type __flags); + template + friend + bool + regex_search(__wrap_iter<_Iter> __first, + __wrap_iter<_Iter> __last, + match_results<__wrap_iter<_Iter>, _Ap>& __m, + const basic_regex<_Cp, _Tp>& __e, + regex_constants::match_flag_type __flags); + template friend class __lookahead; }; @@ -5808,6 +5817,21 @@ regex_search(_BidirectionalIterator __first, _BidirectionalIterator __last, return __r; } +template +inline _LIBCPP_INLINE_VISIBILITY +bool +regex_search(__wrap_iter<_Iter> __first, + __wrap_iter<_Iter> __last, + match_results<__wrap_iter<_Iter>, _Allocator>& __m, + const basic_regex<_CharT, _Traits>& __e, + regex_constants::match_flag_type __flags = regex_constants::match_default) +{ + match_results __mc; + bool __r = __e.__search(__first.base(), __last.base(), __mc, __flags); + __m.__assign(__first, __last, __mc, __flags & regex_constants::__no_update_pos); + return __r; +} + template inline _LIBCPP_INLINE_VISIBILITY bool @@ -6045,7 +6069,7 @@ regex_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++() { __flags_ |= regex_constants::__no_update_pos; _BidirectionalIterator __start = __match_[0].second; - if (__match_.length() == 0) + if (__match_.empty()) { if (__start == __end_) {