[libcxx] r185273 - 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.

Howard Hinnant hhinnant at apple.com
Sat Jun 29 16:45:43 PDT 2013


Author: hhinnant
Date: Sat Jun 29 18:45:43 2013
New Revision: 185273

URL: http://llvm.org/viewvc/llvm-project?rev=185273&view=rev
Log:
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.

Modified:
    libcxx/trunk/include/regex

Modified: libcxx/trunk/include/regex
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/regex?rev=185273&r1=185272&r2=185273&view=diff
==============================================================================
--- libcxx/trunk/include/regex (original)
+++ libcxx/trunk/include/regex Sat Jun 29 18:45:43 2013
@@ -2843,6 +2843,15 @@ private:
                  const basic_regex<_Cp, _Tp>& __e,
                  regex_constants::match_flag_type __flags);
 
+    template <class _Iter, class _Ap, class _Cp, class _Tp>
+    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 <class, class> friend class __lookahead;
 };
 
@@ -5808,6 +5817,21 @@ regex_search(_BidirectionalIterator __fi
     return __r;
 }
 
+template <class _Iter, class _Allocator, class _CharT, class _Traits>
+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<const _CharT*> __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 <class _Allocator, class _CharT, class _Traits>
 inline _LIBCPP_INLINE_VISIBILITY
 bool
@@ -6045,7 +6069,7 @@ regex_iterator<_BidirectionalIterator, _
 {
     __flags_ |= regex_constants::__no_update_pos;
     _BidirectionalIterator __start = __match_[0].second;
-    if (__match_.length() == 0)
+    if (__match_.empty())
     {
         if (__start == __end_)
         {





More information about the cfe-commits mailing list