summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2017-06-22 14:16:38 +0000
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2017-06-22 14:16:38 +0000
commit11e14e4b49ca1b751adf1dd1a73ac32a3f70194f (patch)
tree99bfa141a37aa9487d479465580bc973c654cf44
parentc07fcd5ef1b4c04066b5f13c8889fe960c8ede12 (diff)
downloadgcc-11e14e4b49ca1b751adf1dd1a73ac32a3f70194f.tar.gz
PR libstdc++/81173 fix undefined memset with null pointer
PR libstdc++/81173 * include/bits/stl_bvector.h (vector<bool>::_M_initialize_value): Do not pass null pointer to memset. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@249554 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libstdc++-v3/ChangeLog6
-rw-r--r--libstdc++-v3/include/bits/stl_bvector.h29
2 files changed, 21 insertions, 14 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index f2076a479f5..6be91fedcc5 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,9 @@
+2017-06-22 Jonathan Wakely <jwakely@redhat.com>
+
+ PR libstdc++/81173
+ * include/bits/stl_bvector.h (vector<bool>::_M_initialize_value):
+ Do not pass null pointer to memset.
+
2017-06-21 Ville Voutilainen <ville.voutilainen@gmail.com>
PR libstdc++/80675
diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h
index c9433d4f80f..bf4b23eb2d3 100644
--- a/libstdc++-v3/include/bits/stl_bvector.h
+++ b/libstdc++-v3/include/bits/stl_bvector.h
@@ -364,7 +364,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
return *this;
}
- const_iterator
+ const_iterator
operator+(difference_type __i) const
{
const_iterator __tmp = *this;
@@ -406,7 +406,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
{
if (__first._M_p != __last._M_p)
{
- _Bit_type *__first_p = __first._M_p;
+ _Bit_type* __first_p = __first._M_p;
if (__first._M_offset != 0)
__fill_bvector(__first_p++, __first._M_offset, _S_word_bit, __x);
@@ -509,7 +509,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#else
_Bvector_base() { }
#endif
-
+
_Bvector_base(const allocator_type& __a)
: _M_impl(__a) { }
@@ -632,11 +632,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
: vector(__n, false, __a)
{ }
- vector(size_type __n, const bool& __value,
+ vector(size_type __n, const bool& __value,
const allocator_type& __a = allocator_type())
#else
explicit
- vector(size_type __n, const bool& __value = bool(),
+ vector(size_type __n, const bool& __value = bool(),
const allocator_type& __a = allocator_type())
#endif
: _Base(__a)
@@ -955,7 +955,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
{
std::swap(this->_M_impl._M_start, __x._M_impl._M_start);
std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish);
- std::swap(this->_M_impl._M_end_of_storage,
+ std::swap(this->_M_impl._M_end_of_storage,
__x._M_impl._M_end_of_storage);
_Bit_alloc_traits::_S_on_swap(_M_get_Bit_allocator(),
__x._M_get_Bit_allocator());
@@ -1129,9 +1129,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
void
_M_initialize_value(bool __x)
{
- __builtin_memset(this->_M_impl._M_start._M_p, __x ? ~0 : 0,
- (this->_M_impl._M_end_addr() - this->_M_impl._M_start._M_p)
- * sizeof(_Bit_type));
+ if (_Bit_type* __p = this->_M_impl._M_start._M_p)
+ __builtin_memset(__p, __x ? ~0 : 0,
+ (this->_M_impl._M_end_addr() - __p)
+ * sizeof(_Bit_type));
}
void
@@ -1155,10 +1156,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
template<typename _InputIterator>
- void
+ void
_M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
__false_type)
- { _M_initialize_range(__first, __last,
+ { _M_initialize_range(__first, __last,
std::__iterator_category(__first)); }
template<typename _InputIterator>
@@ -1223,7 +1224,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
else
insert(end(), __first, __last);
}
-
+
template<typename _ForwardIterator>
void
_M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
@@ -1264,7 +1265,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _InputIterator>
void
- _M_insert_range(iterator __pos, _InputIterator __first,
+ _M_insert_range(iterator __pos, _InputIterator __first,
_InputIterator __last, std::input_iterator_tag)
{
for (; __first != __last; ++__first)
@@ -1276,7 +1277,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _ForwardIterator>
void
- _M_insert_range(iterator __position, _ForwardIterator __first,
+ _M_insert_range(iterator __position, _ForwardIterator __first,
_ForwardIterator __last, std::forward_iterator_tag);
void