Index: lib/StaticAnalyzer/Checkers/MallocChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -2346,9 +2346,10 @@ CheckerContext &C) const { ProgramStateRef state = C.getState(); - RegionStateTy RS = state->get(); + RegionStateTy OldRS = state->get(); RegionStateTy::Factory &F = state->get_context(); + RegionStateTy RS = OldRS; SmallVector Errors; for (RegionStateTy::iterator I = RS.begin(), E = RS.end(); I != E; ++I) { if (SymReaper.isDead(I->first)) { @@ -2356,10 +2357,18 @@ Errors.push_back(I->first); // Remove the dead symbol from the map. RS = F.remove(RS, I->first); - } } + if (RS == OldRS) { + // We shouldn't have touched other maps yet. + assert(state->get() == + C.getState()->get()); + assert(state->get() == + C.getState()->get()); + return; + } + // Cleanup the Realloc Pairs Map. ReallocPairsTy RP = state->get(); for (ReallocPairsTy::iterator I = RP.begin(), E = RP.end(); I != E; ++I) {