Editor: Fix NULL-Pointer dereference in cppfunctiondecldeflink

Happen when trying to synchronize a return type in an inapropriate AST.

Task-number:QTCREATORBUG-7073
Change-Id: I6621a3d5539f96c0db9e0d20423dba9a7def98fc
Reviewed-by: Christian Kamm <christian.d.kamm@nokia.com>
This commit is contained in:
David Schulz
2012-03-12 11:02:14 +01:00
committed by Jarek Kobus
parent bb63ec80eb
commit 72e3038629

View File

@@ -613,7 +613,7 @@ Utils::ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targ
LookupContext targetContext(targetFile->cppDocument(), snapshot); LookupContext targetContext(targetFile->cppDocument(), snapshot);
// sync return type // sync return type
{ do {
// set up for rewriting return type // set up for rewriting return type
SubstitutionEnvironment env; SubstitutionEnvironment env;
env.setContext(sourceContext); env.setContext(sourceContext);
@@ -637,6 +637,9 @@ Utils::ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targ
declarator = def->declarator; declarator = def->declarator;
firstReplaceableSpecifier = findFirstReplaceableSpecifier( firstReplaceableSpecifier = findFirstReplaceableSpecifier(
targetTranslationUnit, def->decl_specifier_list); targetTranslationUnit, def->decl_specifier_list);
} else {
// no proper AST to synchronize the return type
break;
} }
int returnTypeStart = 0; int returnTypeStart = 0;
@@ -653,7 +656,7 @@ Utils::ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targ
targetFile->startOf(targetFunctionDeclarator->lparen_token), targetFile->startOf(targetFunctionDeclarator->lparen_token),
replacement); replacement);
} }
} } while (false);
// sync parameters // sync parameters
{ {