Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:42.3:Update
kdevelop4
fix-for-null-pointer-dereference-with-gcc6.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File fix-for-null-pointer-dereference-with-gcc6.patch of Package kdevelop4
From: Kevin Funk <kfunk@kde.org> Date: Mon, 21 Mar 2016 23:39:02 +0000 Subject: Fix places with undefined behavior References: kde#360707 Upstream: submitted New API: IndexedType::IndexedType(const AbstractType::Ptr& type) Places where we may call AbstractPtr::indexed with this being a nullptr. Similar patches probably need to be applied to other language plugins CCMAIL: kdevelop-devel@kde.org CCBUG: 360707 --- --- a/languages/cpp/cppduchain/cppducontext.h +++ b/languages/cpp/cppduchain/cppducontext.h @@ -340,7 +340,9 @@ DelayedType::Ptr delayed( new DelayedType() ); delayed->setIdentifier( i ); - res.type = Cpp::resolveDelayedTypes( delayed.cast<AbstractType>(), this, source, basicFlags & KDevelop::DUContext::NoUndefinedTemplateParams ? DUContext::NoUndefinedTemplateParams : DUContext::NoSearchFlags )->indexed(); + auto resolved = Cpp::resolveDelayedTypes( delayed.cast<AbstractType>(), this, + source, basicFlags & DUContext::NoUndefinedTemplateParams ? DUContext::NoUndefinedTemplateParams : DUContext::NoSearchFlags ); + res.type = IndexedType(resolved); if( basicFlags & KDevelop::DUContext::NoUndefinedTemplateParams) { AbstractType::Ptr targetTypePtr = TypeUtils::unAliasedType(TypeUtils::targetType(res.type.abstractType(), 0)); --- a/languages/cpp/cppduchain/declarationbuilder.cpp +++ b/languages/cpp/cppduchain/declarationbuilder.cpp @@ -371,10 +371,10 @@ foreach (Declaration* dec, declarations) { if (dec->isForwardDeclaration() || dec->isDefinition()) continue; - if (dec->abstractType()->indexed() == lastType()->indexed()) { + if (IndexedType(dec->abstractType()) == IndexedType(lastType())) { //If this declaration is already assigned to a partial match, unassign it if (FunctionDefinition* oldDef = FunctionDefinition::definition(dec)) { - if (oldDef->abstractType()->indexed() != dec->abstractType()->indexed()) + if (IndexedType(oldDef->abstractType()) != IndexedType(dec->abstractType())) oldDef->setDeclaration(0); } funDef->setDeclaration(dec); @@ -1173,7 +1173,7 @@ instance.virtualInheritance = (bool)node->virt; //TypeUtils::unAliasedType( - instance.baseClass = TypeUtils::unAliasedType(lastType())->indexed(); + instance.baseClass = IndexedType(TypeUtils::unAliasedType(lastType())); if(currentClass->classType() == ClassDeclarationData::Struct) instance.access = KDevelop::Declaration::Public; else --- a/languages/cpp/cppduchain/expressionparser.cpp +++ b/languages/cpp/cppduchain/expressionparser.cpp @@ -204,7 +204,7 @@ DUChainReadLocker lock(DUChain::lock()); - ret.type = v.lastType()->indexed(); + ret.type = v.lastType() ? v.lastType()->indexed() : IndexedType(); ret.isInstance = v.lastInstance().isInstance; if(v.lastInstance().declaration) --- a/languages/cpp/cppduchain/name_visitor.cpp +++ b/languages/cpp/cppduchain/name_visitor.cpp @@ -166,7 +166,7 @@ if( m_visitor->lastType() ) { LOCKDUCHAIN; - res.type = m_visitor->lastType()->indexed(); + res.type = IndexedType(m_visitor->lastType()); foreach(const DeclarationPointer &decl, m_visitor->lastDeclarations()) if(decl) res.allDeclarationsList().append(decl->id()); @@ -197,7 +197,7 @@ return ExpressionEvaluationResult(); } - res.type = v.type()->indexed(); + res.type = IndexedType(v.type()); if( res.type ) { LOCKDUCHAIN; --- a/languages/cpp/cppduchain/templatedeclaration.cpp +++ b/languages/cpp/cppduchain/templatedeclaration.cpp @@ -924,7 +924,7 @@ Q_ASSERT(!templateDecl->defaultParameter().isEmpty()); DelayedType::Ptr delayed( new DelayedType() ); delayed->setIdentifier( IndexedTypeIdentifier(templateDecl->defaultParameter()) ); - type = resolveDelayedTypes( delayed.cast<AbstractType>(), surroundingContext, source)->indexed(); + type = IndexedType(resolveDelayedTypes(delayed.cast<AbstractType>(), surroundingContext, source)); } // else the parameter is missing //TODO: why is this neccessary? @@ -1049,7 +1049,7 @@ UnAliasExchanger exchanger(source); for(uint a = 0; a < templateArguments.templateParametersSize(); ++a) - newTemplateArguments.templateParametersList().append(exchanger.exchange(templateArguments.templateParameters()[a].abstractType())->indexed()); + newTemplateArguments.templateParametersList().append(IndexedType(exchanger.exchange(templateArguments.templateParameters()[a].abstractType()))); templateArguments = newTemplateArguments; } --- a/languages/cpp/cppduchain/typeconversion.cpp +++ b/languages/cpp/cppduchain/typeconversion.cpp @@ -206,7 +206,7 @@ if( realTo->modifiers() & AbstractType::ConstModifier ) { //For constant references, the compiler can create a temporary object holding the converted value. So just forget whether the types are references. - conv = implicitConversion( realType(from, m_topContext)->indexed(), realType(to, m_topContext)->indexed(), fromLValue, noUserDefinedConversion ); + conv = implicitConversion( IndexedType(realType(from, m_topContext)), IndexedType(realType(to, m_topContext)), fromLValue, noUserDefinedConversion ); goto ready; } } @@ -361,7 +361,7 @@ if( isReferenceType(from) ) { ///Transform lvalue to rvalue. Iso c++ draft 4.1 modeled roughly - AbstractType::Ptr fromNonConstant = realType(from, m_topContext)->indexed().abstractType(); + AbstractType::Ptr fromNonConstant = IndexedType(realType(from, m_topContext)).abstractType(); //When copying, the type becomes non-constant if(fromNonConstant && fromNonConstant->modifiers() & AbstractType::ConstModifier) @@ -388,7 +388,7 @@ maximizeRank( bestRank, worseRank(rank, ExactMatch ) ); }else if(from->modifiers() & AbstractType::ConstModifier) { ///We can transform a constant lvalue to a non-constant rvalue - AbstractType::Ptr fromNonConstant = from->indexed().abstractType(); + AbstractType::Ptr fromNonConstant = IndexedType(from).abstractType(); fromNonConstant->setModifiers(fromNonConstant->modifiers() & ~(AbstractType::ConstModifier)); ConversionRank ret = standardConversion( fromNonConstant, to, removeCategories(categories,LValueTransformationCategory), maxCategories-1 ); maximizeRank( bestRank, ret ); --- a/languages/cpp/cppduchain/typeutils.cpp +++ b/languages/cpp/cppduchain/typeutils.cpp @@ -234,7 +234,7 @@ foreach(Declaration* decl, internal->findDeclarations(Cpp::castIdentifier().identifier(), CursorInRevision::invalid(), topContext, (DUContext::SearchFlags)(DUContext::DontSearchInParent | DUContext::NoFiltering))) { FunctionType::Ptr funType = decl->type<FunctionType>(); if(funType && funType->returnType()) { - if(conversion.implicitConversion(funType->returnType()->indexed(), matchTo->indexed(), true)) { + if(conversion.implicitConversion(IndexedType(funType->returnType()), IndexedType(matchTo), true)) { return funType->returnType(); } } @@ -292,7 +292,7 @@ { AbstractType::Ptr type = indexedType.abstractType(); removeConstModifier(type); - return type->indexed(); + return IndexedType(type); } void removeConstModifier(AbstractType::Ptr& type)
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor