mirror of
https://github.com/boostorg/container.git
synced 2025-08-02 22:14:26 +02:00
Fixed #142 ("memset called with null pointer")
This commit is contained in:
@@ -1324,6 +1324,7 @@ use [*Boost.Container]? There are several reasons for that:
|
||||
* Fixed bugs:
|
||||
* [@https://github.com/boostorg/container/pull/135 GitHub #135: ['"Missing BOOST_NORETURN for user defined functions"]].
|
||||
* [@https://github.com/boostorg/container/pull/138 GitHub #138: ['"Remove Classes from Global Namespace"]].
|
||||
* [@https://github.com/boostorg/container/issues/142 GitHub #142: ['"memset called with null pointer"]].
|
||||
|
||||
[endsect]
|
||||
|
||||
|
@@ -587,8 +587,10 @@ inline typename dtl::enable_if_memzero_initializable<F, F>::type
|
||||
uninitialized_value_init_alloc_n(Allocator &, typename boost::container::allocator_traits<Allocator>::size_type n, F r)
|
||||
{
|
||||
typedef typename boost::container::iterator_traits<F>::value_type value_type;
|
||||
std::memset((void*)boost::movelib::iterator_to_raw_pointer(r), 0, sizeof(value_type)*n);
|
||||
boost::container::iterator_advance(r, n);
|
||||
if (BOOST_LIKELY(n)){
|
||||
std::memset((void*)boost::movelib::iterator_to_raw_pointer(r), 0, sizeof(value_type)*n);
|
||||
boost::container::iterator_advance(r, n);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -892,8 +894,10 @@ inline typename dtl::enable_if_memtransfer_copy_assignable<I, F, F>::type
|
||||
{
|
||||
typedef typename boost::container::iterator_traits<I>::value_type value_type;
|
||||
const typename boost::container::iterator_traits<I>::difference_type n = boost::container::iterator_distance(f, l);
|
||||
r -= n;
|
||||
std::memmove((boost::movelib::iterator_to_raw_pointer)(r), (boost::movelib::iterator_to_raw_pointer)(f), sizeof(value_type)*n);
|
||||
if (BOOST_LIKELY(n)){
|
||||
r -= n;
|
||||
std::memmove((boost::movelib::iterator_to_raw_pointer)(r), (boost::movelib::iterator_to_raw_pointer)(f), sizeof(value_type)*n);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user