Commit 0f00e084 authored by Nikolai Kosjar's avatar Nikolai Kosjar
Browse files

C++: Fix null pointer access for invalid code



The code snippet provided in the bug report could not be parsed
properly, thus Bind did not generate all expected symbols/names.

The chunk in onConnectOrDisconnectCall() fixes the crash. The other
chunks address triggered QTC_ASSERTs.

Change-Id: Idf508b91b70659d38e59064d4922600f7b31daf8
Task-number: QTCREATORBUG-14709
Reviewed-by: default avatarMarco Bubke <marco.bubke@theqtcompany.com>
parent bb549770
......@@ -1832,7 +1832,7 @@ NameAST *nameUnderCursor(const QList<AST *> &path)
bool canLookupDefinition(const CppQuickFixInterface &interface, const NameAST *nameAst)
{
QTC_ASSERT(nameAst, return false);
QTC_ASSERT(nameAst && nameAst->name, return false);
// Find the enclosing scope
unsigned line, column;
......@@ -1909,7 +1909,7 @@ void AddIncludeForUndefinedIdentifier::match(const CppQuickFixInterface &interfa
QuickFixOperations &result)
{
const NameAST *nameAst = nameUnderCursor(interface.path());
if (!nameAst)
if (!nameAst || !nameAst->name)
return;
if (canLookupDefinition(interface, nameAst))
......@@ -5852,7 +5852,7 @@ bool onConnectOrDisconnectCall(AST *ast, const ExpressionListAST **arguments)
return false;
const IdExpressionAST *idExpr = call->base_expression->asIdExpression();
if (!idExpr)
if (!idExpr || !idExpr->name || !idExpr->name->name)
return false;
const ExpressionListAST *args = call->expression_list;
......
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