Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
windows:mingw:win32
mingw32-kdevplatform4
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 mingw32-kdevplatform4
From: Kevin Funk <kfunk@kde.org> Date: Tue, 22 Mar 2016 12:05:21 +0000 Subject: Fix null-pointer dereference References: kde#360707 Upstream: submitted Fix null-pointer dereference CCBUG: 360707 --- --- a/language/codecompletion/codecompletionitem.cpp +++ b/language/codecompletion/codecompletionitem.cpp @@ -59,8 +59,8 @@ Q_ASSERT(m_parent == 0); m_parent = parent; - CompletionTreeNode* node = parent->asNode(); - if( node ) { + auto node = parent ? parent->asNode() : nullptr; + if (node) { m_rowInParent = node->children.count(); } } --- a/language/duchain/declaration.cpp +++ b/language/duchain/declaration.cpp @@ -276,7 +276,7 @@ ENSURE_CAN_WRITE DUCHAIN_D_DYNAMIC(Declaration); - d->m_type = type->indexed(); + d->m_type = type ? type->indexed() : IndexedType(); updateCodeModel(); } --- a/language/duchain/instantiationinformation.cpp +++ b/language/duchain/instantiationinformation.cpp @@ -61,7 +61,7 @@ } void InstantiationInformation::addTemplateParameter(KDevelop::AbstractType::Ptr type) { - templateParametersList().append(type->indexed()); + templateParametersList().append(IndexedType(type)); } QString InstantiationInformation::toString(bool local) const { --- a/language/duchain/repositories/typerepository.cpp +++ b/language/duchain/repositories/typerepository.cpp @@ -100,7 +100,7 @@ return &typeRepository(); } -uint TypeRepository::indexForType(AbstractType::Ptr input) { +uint TypeRepository::indexForType(const AbstractType::Ptr input) { if(!input) return 0; --- a/language/duchain/repositories/typerepository.h +++ b/language/duchain/repositories/typerepository.h @@ -29,7 +29,7 @@ class TypeRepository { public: - static uint indexForType(AbstractType::Ptr input); + static uint indexForType(const AbstractType::Ptr input); static AbstractType::Ptr typeForIndex(uint index); static void increaseReferenceCount(uint index); static void decreaseReferenceCount(uint index); --- a/language/duchain/topducontext.cpp +++ b/language/duchain/topducontext.cpp @@ -769,7 +769,6 @@ m_predecessor = 0; } - //May also be called when this is zero. bool alreadyImporting(IndexedQualifiedIdentifier id) { ApplyAliasesBuddyInfo* current = this; while(current) { @@ -852,7 +851,7 @@ continue; } - if(buddy->alreadyImporting( importIdentifier )) + if(buddy && buddy->alreadyImporting( importIdentifier )) continue; //This import has already been applied to this search ApplyAliasesBuddyInfo info(1, buddy, importIdentifier); @@ -928,7 +927,7 @@ continue; } - if(buddy->alreadyImporting( importIdentifier )) + if(buddy && buddy->alreadyImporting( importIdentifier )) continue; //This import has already been applied to this search ApplyAliasesBuddyInfo info(2, buddy, importIdentifier); --- a/language/duchain/types/abstracttype.cpp +++ b/language/duchain/types/abstracttype.cpp @@ -96,7 +96,7 @@ IndexedType AbstractType::indexed() const { - return IndexedType(TypeRepository::indexForType(AbstractType::Ptr(const_cast<AbstractType*>(this)))); + return IndexedType(AbstractType::Ptr(const_cast<AbstractType*>(this))); } bool AbstractType::equals(const AbstractType* rhs) const --- a/language/duchain/types/arraytype.cpp +++ b/language/duchain/types/arraytype.cpp @@ -83,7 +83,7 @@ void ArrayType::setElementType(AbstractType::Ptr type) { - d_func_dynamic()->m_elementType = type->indexed(); + d_func_dynamic()->m_elementType = IndexedType(type); } QString ArrayType::toString() const @@ -107,7 +107,7 @@ void ArrayType::exchangeTypes( TypeExchanger* exchanger ) { TYPE_D_DYNAMIC(ArrayType); - d->m_elementType = exchanger->exchange( d->m_elementType.abstractType() )->indexed(); + d->m_elementType = IndexedType(exchanger->exchange(d->m_elementType.abstractType())); } AbstractType::WhichType ArrayType::whichType() const --- a/language/duchain/types/containertypes.cpp +++ b/language/duchain/types/containertypes.cpp @@ -51,12 +51,12 @@ void ListType::replaceContentType(AbstractType::Ptr newType) { - d_func_dynamic()->m_contentType = newType->indexed(); + d_func_dynamic()->m_contentType = IndexedType(newType); } void MapType::replaceKeyType(AbstractType::Ptr newType) { - d_func_dynamic()->m_keyType = newType->indexed(); + d_func_dynamic()->m_keyType = IndexedType(newType); } IndexedType ListType::contentType() const --- a/language/duchain/types/containertypes.h +++ b/language/duchain/types/containertypes.h @@ -99,7 +99,7 @@ void addContentType(AbstractType::Ptr typeToAdd) { auto newContentType = TypeUtils::mergeTypes<LanguageUnsureType>(contentType().abstractType(), typeToAdd); DUChainWriteLocker lock; - d_func_dynamic()->m_contentType = newContentType->indexed(); + d_func_dynamic()->m_contentType = IndexedType(newContentType); }; /** @@ -175,7 +175,7 @@ { auto newKeyType = TypeUtils::mergeTypes<LanguageUnsureType>(keyType().abstractType(), typeToAdd); DUChainWriteLocker lock; - d_func_dynamic()->m_keyType = newKeyType->indexed(); + d_func_dynamic()->m_keyType = IndexedType(newKeyType); } /** --- a/language/duchain/types/functiontype.cpp +++ b/language/duchain/types/functiontype.cpp @@ -85,9 +85,9 @@ void FunctionType::addArgument(AbstractType::Ptr argument, int index) { if ( index == -1 ) - d_func_dynamic()->m_argumentsList().append(argument->indexed()); + d_func_dynamic()->m_argumentsList().append(IndexedType(argument)); else - d_func_dynamic()->m_argumentsList().insert(index, argument->indexed()); + d_func_dynamic()->m_argumentsList().insert(index, IndexedType(argument)); } void FunctionType::removeArgument(int i) @@ -97,7 +97,7 @@ void FunctionType::setReturnType(AbstractType::Ptr returnType) { - d_func_dynamic()->m_returnType = returnType->indexed(); + d_func_dynamic()->m_returnType = IndexedType(returnType); } AbstractType::Ptr FunctionType::returnType () const @@ -142,8 +142,8 @@ { TYPE_D_DYNAMIC(FunctionType); for (uint i = 0; i < d->m_argumentsSize (); ++i) - d->m_argumentsList()[i] = exchanger->exchange( d->m_arguments()[i].abstractType() )->indexed(); - d->m_returnType = exchanger->exchange(d->m_returnType.abstractType())->indexed(); + d->m_argumentsList()[i] = IndexedType(exchanger->exchange(d->m_arguments()[i].abstractType())); + d->m_returnType = IndexedType(exchanger->exchange(d->m_returnType.abstractType())); } QString FunctionType::partToString( SignaturePart sigPart ) const { --- a/language/duchain/types/indexedtype.cpp +++ b/language/duchain/types/indexedtype.cpp @@ -23,6 +23,13 @@ namespace KDevelop { + +IndexedType::IndexedType(const AbstractType::Ptr& type) + : m_index(TypeRepository::indexForType(type)) +{ + if(m_index && shouldDoDUChainReferenceCounting(this)) + TypeRepository::increaseReferenceCount(m_index, this); +} IndexedType::IndexedType(uint index) : m_index(index) { if(m_index && shouldDoDUChainReferenceCounting(this)) --- a/language/duchain/types/indexedtype.h +++ b/language/duchain/types/indexedtype.h @@ -36,11 +36,9 @@ */ class KDEVPLATFORMLANGUAGE_EXPORT IndexedType : public ReferenceCountManager { public: - /// Constructor. IndexedType(const IndexedType& rhs); + explicit IndexedType(const AbstractType::Ptr& type); explicit IndexedType(uint index = 0); - // prevent upcasting - IndexedType(bool) = delete; ~IndexedType(); --- a/language/duchain/types/pointertype.cpp +++ b/language/duchain/types/pointertype.cpp @@ -70,7 +70,7 @@ } void PointerType::exchangeTypes( TypeExchanger* exchanger ) { - d_func_dynamic()->m_baseType = exchanger->exchange( d_func()->m_baseType.abstractType() )->indexed(); + d_func_dynamic()->m_baseType = IndexedType(exchanger->exchange( d_func()->m_baseType.abstractType())); } PointerType::~PointerType() @@ -84,7 +84,7 @@ void PointerType::setBaseType(AbstractType::Ptr type) { - d_func_dynamic()->m_baseType = type->indexed(); + d_func_dynamic()->m_baseType = IndexedType(type); } QString PointerType::toString() const --- a/language/duchain/types/referencetype.cpp +++ b/language/duchain/types/referencetype.cpp @@ -73,7 +73,7 @@ void ReferenceType::setBaseType(AbstractType::Ptr type) { - d_func_dynamic()->m_baseType = type->indexed(); + d_func_dynamic()->m_baseType = IndexedType(type); } bool ReferenceType::isRValue() const @@ -96,7 +96,7 @@ void ReferenceType::exchangeTypes( TypeExchanger* exchanger ) { - d_func_dynamic()->m_baseType = exchanger->exchange( d_func()->m_baseType.abstractType() )->indexed(); + d_func_dynamic()->m_baseType = IndexedType(exchanger->exchange(d_func()->m_baseType.abstractType())); } QString ReferenceType::toString() const --- a/language/duchain/types/typealiastype.cpp +++ b/language/duchain/types/typealiastype.cpp @@ -58,7 +58,7 @@ void TypeAliasType::setType(AbstractType::Ptr type) { - d_func_dynamic()->m_type = type->indexed(); + d_func_dynamic()->m_type = IndexedType(type); } uint TypeAliasType::hash() const @@ -91,7 +91,7 @@ } void TypeAliasType::exchangeTypes(KDevelop::TypeExchanger* exchanger) { - d_func_dynamic()->m_type = exchanger->exchange( d_func()->m_type.abstractType() )->indexed(); + d_func_dynamic()->m_type = IndexedType(exchanger->exchange(d_func()->m_type.abstractType())); }
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