From 26abe0255db14c39459cbcf4118e31432cd30a78 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Tue, 30 Oct 2018 11:33:31 -0400 Subject: [PATCH] Precautions also in TrackIterRange::StaringWith() as in EndingAfter() --- src/Track.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Track.h b/src/Track.h index 08978aa27..84a17cc9b 100644 --- a/src/Track.h +++ b/src/Track.h @@ -980,7 +980,8 @@ private: return !this->mPred || this->mPred( pTrack ); } - // This friendship is needed in TrackIterRange::EndingAfter() + // This friendship is needed in TrackIterRange::StartingWith and + // TrackIterRange::EndingAfter() friend TrackIterRange< TrackType >; // The class invariant is that mIter == mEnd, or else, mIter != mEnd and @@ -1057,9 +1058,15 @@ template < TrackIterRange StartingWith( const Track *pTrack ) const { + auto newBegin = this->find( pTrack ); + // More careful construction is needed so that the independent + // increment and decrement of each iterator in the NEW pair + // has the expected behavior at boundaries of the range return { - this->find( pTrack ), - this->second + { newBegin.mIter, newBegin.mIter, this->second.mEnd, + this->first.GetPredicate() }, + { newBegin.mIter, this->second.mEnd, this->second.mEnd, + this->second.GetPredicate() } }; }