- Don't increment before we dereference!
- We need to update the iterator before we delete the item.
This code is changed in master, so this fix is for cuttlefish only.
Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Greg Farnum <greg@inktank.com>
void LogSegment::remove_pending_backtraces(inodeno_t ino, int64_t pool) {
elist<BacktraceInfo*>::iterator i = update_backtraces.begin();
- while(!i.end()) {
- ++i;
- if((*i)->bt.ino == ino && (*i)->location == pool) {
- delete (*i);
+ while (!i.end()) {
+ BacktraceInfo *bi = *i;
+ if (bi->bt.ino == ino && bi->location == pool) {
+ ++i;
+ delete bi;
+ } else {
+ ++i;
}
}
}