aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorTim Shen <timshen91@gmail.com>2013-08-16 09:06:31 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2013-08-16 09:06:31 +0000
commit5073d50905684dc9069c9e047ed00335450bfe47 (patch)
tree4f95f8cb1172f1e24794a063ba9c7dc4460e666a /libstdc++-v3
parent639dc669ec1690bc413131c177d50e3b5c5924c9 (diff)
downloadgcc-5073d50905684dc9069c9e047ed00335450bfe47.zip
gcc-5073d50905684dc9069c9e047ed00335450bfe47.tar.gz
gcc-5073d50905684dc9069c9e047ed00335450bfe47.tar.bz2
regex.h (regex_traits<>::transform_primary): Avoid past-the-end dereferences.
2013-08-16 Tim Shen <timshen91@gmail.com> * include/bits/regex.h (regex_traits<>::transform_primary): Avoid past-the-end dereferences. From-SVN: r201783
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog5
-rw-r--r--libstdc++-v3/include/bits/regex.h21
2 files changed, 12 insertions, 14 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 8fea147..0c1cb43 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,8 @@
+2013-08-16 Tim Shen <timshen91@gmail.com>
+
+ * include/bits/regex.h (regex_traits<>::transform_primary):
+ Avoid past-the-end dereferences.
+
2013-08-14 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/58163
diff --git a/libstdc++-v3/include/bits/regex.h b/libstdc++-v3/include/bits/regex.h
index 2776749..8fa979f 100644
--- a/libstdc++-v3/include/bits/regex.h
+++ b/libstdc++-v3/include/bits/regex.h
@@ -220,19 +220,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
string_type
transform_primary(_Fwd_iter __first, _Fwd_iter __last) const
{
- __try
- {
- typedef std::ctype<char_type> __ctype_type;
- const __ctype_type& __fctyp(use_facet<__ctype_type>(_M_locale));
- std::vector<char_type> __v(__first, __last);
- // FIXME : this is not entirely correct
- __fctyp.tolower(&*__v.begin(), &*__v.end());
- return this->transform(&*__v.begin(), &*__v.end());
- }
- __catch (std::bad_cast)
- {
- }
- return string_type();
+ typedef std::ctype<char_type> __ctype_type;
+ const __ctype_type& __fctyp(use_facet<__ctype_type>(_M_locale));
+ std::vector<char_type> __s(__first, __last);
+ // FIXME : this is not entirely correct
+ __fctyp.tolower(__s.data(), __s.data() + __s.size());
+ return this->transform(__s.data(), __s.data() + __s.size());
}
/**
@@ -572,7 +565,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
std::string __s(__last - __first, '?');
__fctyp.narrow(__first, __last, '?', &__s[0]);
- __cctyp.tolower(&*__s.begin(), &*__s.end());
+ __cctyp.tolower(&*__s.begin(), &*__s.begin() + __s.size());
for (_ClassnameEntry* __it = __classnames;
__it < *(&__classnames + 1);
++__it)