From 72e303862983d51ffd25fa454351c5e005514153 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Mon, 12 Mar 2012 11:02:14 +0100 Subject: [PATCH] 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 --- src/plugins/cppeditor/cppfunctiondecldeflink.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/plugins/cppeditor/cppfunctiondecldeflink.cpp b/src/plugins/cppeditor/cppfunctiondecldeflink.cpp index b7af611ae23..2534df0d97b 100644 --- a/src/plugins/cppeditor/cppfunctiondecldeflink.cpp +++ b/src/plugins/cppeditor/cppfunctiondecldeflink.cpp @@ -613,7 +613,7 @@ Utils::ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targ LookupContext targetContext(targetFile->cppDocument(), snapshot); // sync return type - { + do { // set up for rewriting return type SubstitutionEnvironment env; env.setContext(sourceContext); @@ -637,6 +637,9 @@ Utils::ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targ declarator = def->declarator; firstReplaceableSpecifier = findFirstReplaceableSpecifier( targetTranslationUnit, def->decl_specifier_list); + } else { + // no proper AST to synchronize the return type + break; } int returnTypeStart = 0; @@ -653,7 +656,7 @@ Utils::ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targ targetFile->startOf(targetFunctionDeclarator->lparen_token), replacement); } - } + } while (false); // sync parameters {