Commit b6d03af0 by Jonathan Wakely Committed by Jonathan Wakely

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.

From-SVN: r249554
parent 0759db19
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> 2017-06-21 Ville Voutilainen <ville.voutilainen@gmail.com>
PR libstdc++/80675 PR libstdc++/80675
......
...@@ -406,7 +406,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -406,7 +406,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
{ {
if (__first._M_p != __last._M_p) 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) if (__first._M_offset != 0)
__fill_bvector(__first_p++, __first._M_offset, _S_word_bit, __x); __fill_bvector(__first_p++, __first._M_offset, _S_word_bit, __x);
...@@ -1129,8 +1129,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -1129,8 +1129,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
void void
_M_initialize_value(bool __x) _M_initialize_value(bool __x)
{ {
__builtin_memset(this->_M_impl._M_start._M_p, __x ? ~0 : 0, if (_Bit_type* __p = this->_M_impl._M_start._M_p)
(this->_M_impl._M_end_addr() - this->_M_impl._M_start._M_p) __builtin_memset(__p, __x ? ~0 : 0,
(this->_M_impl._M_end_addr() - __p)
* sizeof(_Bit_type)); * sizeof(_Bit_type));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment