Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASAN found _two_ bugs in _Copy_vbool! #4045

Merged
merged 3 commits into from
Sep 22, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Stephan's review comments
CaseyCarter committed Sep 22, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 1f08c28112caa0e77a0d97d29e5c8ed054495df5
6 changes: 3 additions & 3 deletions stl/inc/vector
Original file line number Diff line number Diff line change
@@ -3748,7 +3748,7 @@ _CONSTEXPR20 _OutIt _Copy_vbool(_VbIt _First, _VbIt _Last, _OutIt _Dest) {
const auto _LastDestMask = static_cast<_Vbase>(-1) << _DestEnd._Myoff;

const bool _IsSingleBlockSource = _VbFirst == _VbLast;
const bool _IsSingleBlockDest = _VbDest == _DestEnd._Myptr - (_DestEnd._Myoff ? 0 : 1);
const bool _IsSingleBlockDest = _VbDest == _DestEnd._Myptr - (_DestEnd._Myoff == 0 ? 1 : 0);
const bool _IsRightShift = _Dest._Myoff < _First._Myoff;
if (_IsSingleBlockSource) {
// We already excluded _First == _Last, so here _Last._Myoff > 0 and the shift is safe
@@ -3757,7 +3757,7 @@ _CONSTEXPR20 _OutIt _Copy_vbool(_VbIt _First, _VbIt _Last, _OutIt _Dest) {
const auto _SourceVal = _IsRightShift ? (*_VbFirst & _SourceMask) >> _SourceShift //
: (*_VbFirst & _SourceMask) << _SourceShift;
if (_IsSingleBlockDest) {
const auto _DestMask = _FirstDestMask | (_DestEnd._Myoff ? _LastDestMask : 0);
const auto _DestMask = _FirstDestMask | (_DestEnd._Myoff == 0 ? 0 : _LastDestMask);
*_VbDest = (*_VbDest & _DestMask) | _SourceVal;
} else {
*_VbDest = (*_VbDest & _FirstDestMask) | _SourceVal;
@@ -3774,7 +3774,7 @@ _CONSTEXPR20 _OutIt _Copy_vbool(_VbIt _First, _VbIt _Last, _OutIt _Dest) {
const auto _SourceVal = _IsRightShift ? (*_VbFirst & _FirstSourceMask) >> _SourceShift //
: (*_VbFirst & _FirstSourceMask) << _SourceShift;

const auto _DestMask = _FirstDestMask | (_DestEnd._Myoff ? _LastDestMask : 0);
const auto _DestMask = _FirstDestMask | (_DestEnd._Myoff == 0 ? 0 : _LastDestMask);
if (_Last._Myoff != 0) {
const auto _LastShift = _DestEnd._Myoff - _Last._Myoff;
const auto _LastSourceVal = (*_VbLast & _LastSourceMask) << _LastShift;