Skip to content

Commit

Permalink
Add missing precondition check in forward_list::splice_after
Browse files Browse the repository at this point in the history
`forward_list::splice_after(target_iterator, some_list, before_source_iterator)` requires that `++before_source_iterator` - the iterator that denotes the element to be removed from `some_list` and inserted into `*this` after `target_iterator` - be dereferenceable. We conventionally don't check preconditions when the result of violation is to dereference a `nullptr`, since the behavior is nicely predictable, but doing so here avoids confusion about what otherwise seems like a reasonable call. (See DevDiv-1456054.)
  • Loading branch information
CaseyCarter committed Jul 13, 2021
1 parent 280347a commit 4b22528
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions stl/inc/forward_list
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,7 @@ public:
_Where._Getcont() == _STD addressof(_Mypair._Myval2), "forward_list splice_after iterator outside range");
_STL_VERIFY(_First._Getcont() == _STD addressof(_Right._Mypair._Myval2),
"forward_list splice_after iterator outside range");
_STL_VERIFY(_First._Ptr->_Next != nullptr, "forward_list splice_after iterator outside range");
#endif // _ITERATOR_DEBUG_LEVEL == 2

_Splice_after(_Where._Ptr, _Right, _First._Ptr);
Expand Down

0 comments on commit 4b22528

Please sign in to comment.