diff options
| author | Mark de Wever <koraq@xs4all.nl> | 2025-02-27 17:47:34 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-27 17:47:34 +0100 |
| commit | da618cf0a76371ca89769ca706fe39cc92fbf7d6 (patch) | |
| tree | 6d48c317445a1855307061986dc271337196f93b /libcxx/include/__split_buffer | |
| parent | 69effe054c136defda8766688ac0de4626a0eb05 (diff) | |
[NFC][libc++] Guard against operator& hijacking. (#128351)
This set usage of operator& instead of std::addressof seems not be easy
to "abuse". Some seem easy to misuse, like basic_ostream::operator<<,
trying to do that results in compilation errors since the `widen`
function is not specialized for the hijacking character type. Hence
there are no tests.
Diffstat (limited to 'libcxx/include/__split_buffer')
| -rw-r--r-- | libcxx/include/__split_buffer | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/libcxx/include/__split_buffer b/libcxx/include/__split_buffer index a8f679cc30a9..721d4d497f2a 100644 --- a/libcxx/include/__split_buffer +++ b/libcxx/include/__split_buffer @@ -233,7 +233,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __split_buffer<_Tp, _Allocator>::__invariants // Postcondition: size() == size() + __n template <class _Tp, class _Allocator> _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n) { - _ConstructTransaction __tx(&this->__end_, __n); + _ConstructTransaction __tx(std::addressof(this->__end_), __n); for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) { __alloc_traits::construct(__alloc_, std::__to_address(__tx.__pos_)); } @@ -248,7 +248,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::__construct_ template <class _Tp, class _Allocator> _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) { - _ConstructTransaction __tx(&this->__end_, __n); + _ConstructTransaction __tx(std::addressof(this->__end_), __n); for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) { __alloc_traits::construct(__alloc_, std::__to_address(__tx.__pos_), __x); } @@ -283,7 +283,7 @@ template <class _Tp, class _Allocator> template <class _ForwardIterator> _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::__construct_at_end_with_size(_ForwardIterator __first, size_type __n) { - _ConstructTransaction __tx(&this->__end_, __n); + _ConstructTransaction __tx(std::addressof(this->__end_), __n); for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_, (void)++__first) { __alloc_traits::construct(__alloc_, std::__to_address(__tx.__pos_), *__first); } |
