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
This commit is contained in:
Jonathan Wakely 2017-06-22 15:16:38 +01:00 committed by Jonathan Wakely
parent 0759db190d
commit b6d03af0b1
2 changed files with 21 additions and 14 deletions

View File

@ -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

View File

@ -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);
@ -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