From 62fd2713d00ed3756cead7072cbbd61e631e6670 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Mon, 5 Mar 2012 13:00:10 +0100 Subject: [PATCH] Editor: Fix NULL-Pointer dereference in cppinsertdecldef Task-number: QTCREATORBUG-7030 Change-Id: Id2467f24dff289b6d23407ea15b181f76c8fd2e7 Reviewed-by: Leandro Melo --- src/plugins/cppeditor/cppinsertdecldef.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/plugins/cppeditor/cppinsertdecldef.cpp b/src/plugins/cppeditor/cppinsertdecldef.cpp index 47e4e28a000..87cb345dbae 100644 --- a/src/plugins/cppeditor/cppinsertdecldef.cpp +++ b/src/plugins/cppeditor/cppinsertdecldef.cpp @@ -533,6 +533,7 @@ QPair assembleDeclarationData(const QString &specifiers, const CppRefactoringFilePtr &file, const Overview &printer) { + QTC_ASSERT(decltr, return (QPair())); if (decltr->core_declarator && decltr->core_declarator->asDeclaratorId() && decltr->core_declarator->asDeclaratorId()->name) { @@ -788,14 +789,16 @@ QList ExtractFunction::match( it; it = it->next) { ParameterDeclarationAST *paramDecl = it->value->asParameterDeclaration(); - const QString &specifiers = - file->textOf(file->startOf(paramDecl), - file->endOf(paramDecl->type_specifier_list->lastValue())); - const QPair &p = - assembleDeclarationData(specifiers, paramDecl->declarator, file, printer); - if (!p.first.isEmpty()) { - analyser.m_knownDecls.insert(p.first, p.second); - refFuncParams.insert(p.first); + if (paramDecl->declarator) { + const QString &specifiers = + file->textOf(file->startOf(paramDecl), + file->endOf(paramDecl->type_specifier_list->lastValue())); + const QPair &p = + assembleDeclarationData(specifiers, paramDecl->declarator, file, printer); + if (!p.first.isEmpty()) { + analyser.m_knownDecls.insert(p.first, p.second); + refFuncParams.insert(p.first); + } } } }