Invented a fix that compiles on GCC and doesn't crash.

This commit is contained in:
PKEuS 2012-09-02 16:53:38 +02:00
parent 794a491515
commit 7bd732efe4
1 changed files with 9 additions and 2 deletions

View File

@ -704,13 +704,20 @@ void CheckOther::checkRedundantAssignment()
if (!_tokenizer->IsScopeNoReturn(funcEnd, &noreturn) && !noreturn) {
for (std::map<unsigned int, const Token*>::iterator i = varAssignments.begin(); i != varAssignments.end(); ++i) {
const Variable* var = symbolDatabase->getVariableFromVarId(i->first);
if (!var || (!var->isLocal() && !var->isArgument()))
if (!var || (!var->isLocal() && !var->isArgument())) {
varAssignments.erase(i++);
if (i == varAssignments.end())
break;
}
}
for (std::map<unsigned int, const Token*>::iterator i = memAssignments.begin(); i != memAssignments.end(); ++i) {
const Variable* var = symbolDatabase->getVariableFromVarId(i->first);
if (!var || (!var->isLocal() && !var->isArgument()))
if (!var || (!var->isLocal() && !var->isArgument())) {
memAssignments.erase(i++);
if (i == memAssignments.end())
break;
}
}
} else {
varAssignments.clear();