From 85c501c976e330765c392e212cf2775b563ddaea Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Thu, 9 Jul 2009 16:20:20 +0200 Subject: [PATCH] Fixed possible crash when completing function-like arguments. --- src/libs/cplusplus/ResolveExpression.cpp | 4 ++-- src/plugins/cpptools/cppcodecompletion.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/cplusplus/ResolveExpression.cpp b/src/libs/cplusplus/ResolveExpression.cpp index 9124087b6c6..7f53de1ed5f 100644 --- a/src/libs/cplusplus/ResolveExpression.cpp +++ b/src/libs/cplusplus/ResolveExpression.cpp @@ -670,7 +670,7 @@ ResolveExpression::resolveMemberExpression(const QList &baseResults, if (NamedType *namedTy = ty->asNamedType()) results += resolveMember(p, memberName, namedTy); else if (Function *fun = ty->asFunctionType()) { - if (fun->scope()->isBlockScope() || fun->scope()->isNamespaceScope()) { + if (fun->scope() && (fun->scope()->isBlockScope() || fun->scope()->isNamespaceScope())) { ty = fun->returnType(); if (ReferenceType *refTy = ty->asReferenceType()) @@ -897,7 +897,7 @@ QList ResolveClass::resolveClass(NamedType *namedTy, if (Function *funTy = decl->type()->asFunctionType()) { // QString foo("ciao"); // foo. - if (funTy->scope()->isBlockScope() || funTy->scope()->isNamespaceScope()) { + if (funTy->scope() && (funTy->scope()->isBlockScope() || funTy->scope()->isNamespaceScope())) { const ResolveExpression::Result r(funTy->returnType(), decl); resolvedSymbols += resolveClass(r, context); } diff --git a/src/plugins/cpptools/cppcodecompletion.cpp b/src/plugins/cpptools/cppcodecompletion.cpp index 2770184978f..37e307ea9fd 100644 --- a/src/plugins/cpptools/cppcodecompletion.cpp +++ b/src/plugins/cpptools/cppcodecompletion.cpp @@ -1013,7 +1013,7 @@ bool CppCodeCompletion::completeMember(const QList &re namedTy = ty->asNamedType(); if (! namedTy) { Function *fun = ty->asFunctionType(); - if (fun && (fun->scope()->isBlockScope() || fun->scope()->isNamespaceScope())) + if (fun && fun->scope() && (fun->scope()->isBlockScope() || fun->scope()->isNamespaceScope())) namedTy = fun->returnType()->asNamedType(); } }