summaryrefslogtreecommitdiffstats
path: root/libcxx/include/regex
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2013-07-11 15:32:55 +0000
committerHoward Hinnant <hhinnant@apple.com>2013-07-11 15:32:55 +0000
commitc815a4e2977b33d6fd9f7dc2acf2126b5ecd369f (patch)
tree7ea90eab36430925819bf9245a1f8ecf8a17cbe8 /libcxx/include/regex
parente97c71b8fddcbf61fdbfb13b520761d05a646a2c (diff)
downloadbcm5719-llvm-c815a4e2977b33d6fd9f7dc2acf2126b5ecd369f.tar.gz
bcm5719-llvm-c815a4e2977b33d6fd9f7dc2acf2126b5ecd369f.zip
Bill Fisher: This patch fixes a less likely case where '\b' can back up into invalid memory, when driven by a regex_iterator (for case 1, see r185273 or http://llvm.org/bugs/show_bug.cgi?id=16240)
The attached test program also supplies a test for the case 1 fix in r185273. llvm-svn: 186089
Diffstat (limited to 'libcxx/include/regex')
-rw-r--r--libcxx/include/regex5
1 files changed, 3 insertions, 2 deletions
diff --git a/libcxx/include/regex b/libcxx/include/regex
index 36d5677072f..19e08b13aaf 100644
--- a/libcxx/include/regex
+++ b/libcxx/include/regex
@@ -5811,9 +5811,10 @@ regex_search(_BidirectionalIterator __first, _BidirectionalIterator __last,
const basic_regex<_CharT, _Traits>& __e,
regex_constants::match_flag_type __flags = regex_constants::match_default)
{
- basic_string<_CharT> __s(__first, __last);
+ int __offset = (__flags & regex_constants::match_prev_avail) ? 1 : 0;
+ basic_string<_CharT> __s(_VSTD::prev(__first, __offset), __last);
match_results<const _CharT*> __mc;
- bool __r = __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags);
+ bool __r = __e.__search(__s.data() + __offset, __s.data() + __s.size(), __mc, __flags);
__m.__assign(__first, __last, __mc, __flags & regex_constants::__no_update_pos);
return __r;
}
OpenPOWER on IntegriCloud