Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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.
  • Loading branch information...
commit 70a7c8024a3b14ebef257ec6a3d94f4f545fe834 1 parent 0496a8f
Anton Lundin glance- authored committed
Showing with 6 additions and 0 deletions.
  1. +6 −0 src/statesync/user.cc
6 src/statesync/user.cc
View
@@ -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();
Please sign in to comment.
Something went wrong with that request. Please try again.