We can't iterate over the object we are modifying
If subtract is called on itself, prefix and this is the same and the iterator is invalid after modifying the underlaying object. Instead just clear everyting. Closes #354. Closes #355.
This commit is contained in:
committed by
Keith Winstein
parent
0496a8f244
commit
70a7c8024a
@@ -43,9 +43,15 @@ using namespace ClientBuffers;
|
||||
|
||||
void UserStream::subtract( const UserStream *prefix )
|
||||
{
|
||||
// if we are subtracting ourself from ourself, just clear the deque
|
||||
if ( this == prefix ) {
|
||||
actions.clear();
|
||||
return;
|
||||
}
|
||||
for ( deque<UserEvent>::const_iterator i = prefix->actions.begin();
|
||||
i != prefix->actions.end();
|
||||
i++ ) {
|
||||
assert( this != prefix );
|
||||
assert( !actions.empty() );
|
||||
assert( *i == actions.front() );
|
||||
actions.pop_front();
|
||||
|
||||
Reference in New Issue
Block a user