forked from qt-creator/qt-creator
CppEditor: Fix possible crash in CompleteSwitchCaseStatement
There can be an unexpected null pointer if the built-in code model fails to parse the code properly. Fixes: QTCREATORBUG-26316 Change-Id: I5751be505b1182df17f58e1a174d645cef1e95cf Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -2483,7 +2483,7 @@ void CompleteSwitchCaseStatement::match(const CppQuickFixInterface &interface,
|
|||||||
AST *ast = path.at(depth);
|
AST *ast = path.at(depth);
|
||||||
SwitchStatementAST *switchStatement = ast->asSwitchStatement();
|
SwitchStatementAST *switchStatement = ast->asSwitchStatement();
|
||||||
if (switchStatement) {
|
if (switchStatement) {
|
||||||
if (!switchStatement->statement)
|
if (!switchStatement->statement || !switchStatement->symbol)
|
||||||
return;
|
return;
|
||||||
CompoundStatementAST *compoundStatement = switchStatement->statement->asCompoundStatement();
|
CompoundStatementAST *compoundStatement = switchStatement->statement->asCompoundStatement();
|
||||||
if (!compoundStatement) // we ignore pathologic case "switch (t) case A: ;"
|
if (!compoundStatement) // we ignore pathologic case "switch (t) case A: ;"
|
||||||
|
Reference in New Issue
Block a user