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.
  • Loading branch information...
commit 1fad5a476e99eab61e5923bff934a95e8a5aef5b 1 parent 0496a8f
@glance- authored
Showing with 6 additions and 0 deletions.
  1. +6 −0 src/statesync/user.cc
View
6 src/statesync/user.cc
@@ -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.