Commit 323be40b authored by Nikolai Kosjar's avatar Nikolai Kosjar
Browse files

CppEditor: Fix stack overflow in quick fixes



The MoveDeclarationOutOfIf quick fix modified a IfStatementAST in case
there were several such ASTs in interface->path(). The resulting AST was
invalid (else_statement was pointing to 'this' afterwards), thus the
afterwards executed PointerDeclarationFormatter (an ASTVisitor) was not
able to finish his visit.

The actual problem was that op->pattern in the match() calls was not
reset.

Task-number: QTCREATORBUG-10919
Change-Id: Ifbcac73e75690321ef45b6d8c2dc32fcea236efa
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
parent bd82f038
......@@ -774,6 +774,11 @@ public:
setDescription(QApplication::translate("CppTools::QuickFix",
"Move Declaration out of Condition"));
reset();
}
void reset()
{
condition = mk.Condition();
pattern = mk.IfStatement(condition);
}
......@@ -826,6 +831,8 @@ void MoveDeclarationOutOfIf::match(const CppQuickFixInterface &interface,
result.append(op);
return;
}
op->reset();
}
}
}
......@@ -841,7 +848,11 @@ public:
{
setDescription(QApplication::translate("CppTools::QuickFix",
"Move Declaration out of Condition"));
reset();
}
void reset()
{
condition = mk.Condition();
pattern = mk.WhileStatement(condition);
}
......@@ -903,6 +914,8 @@ void MoveDeclarationOutOfWhile::match(const CppQuickFixInterface &interface,
result.append(op);
return;
}
op->reset();
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment