compilerplugins/clang/plugin.cxx | 4 ++++ include/svl/stylepool.hxx | 2 +- svl/source/items/stylepool.cxx | 9 +++++---- sw/source/core/doc/swstylemanager.cxx | 6 ++---- 4 files changed, 12 insertions(+), 9 deletions(-)
New commits: commit 1476d95b6ed3afa35cccc46f61865ea938b62144 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Mon Sep 10 14:49:17 2018 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Sep 11 08:17:42 2018 +0200 loplugin:useuniqueptr in StylePool::createIterator Change-Id: I1a7bdfc00352c25f5d2db9ef195000d16f909537 Reviewed-on: https://gerrit.libreoffice.org/60263 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/include/svl/stylepool.hxx b/include/svl/stylepool.hxx index 497ae845a36b..5fe2f2197186 100644 --- a/include/svl/stylepool.hxx +++ b/include/svl/stylepool.hxx @@ -62,7 +62,7 @@ public: @postcond the iterator "points before the first" SfxItemSet of the pool. The first StylePoolIterator::getNext() call will deliver the first SfxItemSet. */ - IStylePoolIteratorAccess* createIterator( const bool bSkipUnusedItemSets = false, + std::unique_ptr<IStylePoolIteratorAccess> createIterator( const bool bSkipUnusedItemSets = false, const bool bSkipIgnorableItems = false ); ~StylePool(); diff --git a/svl/source/items/stylepool.cxx b/svl/source/items/stylepool.cxx index f1ddc7e0ab7b..6192adee6650 100644 --- a/svl/source/items/stylepool.cxx +++ b/svl/source/items/stylepool.cxx @@ -20,6 +20,7 @@ #include <svl/stylepool.hxx> #include <svl/itemiter.hxx> #include <svl/itempool.hxx> +#include <o3tl/make_unique.hxx> #include <algorithm> #include <map> #include <memory> @@ -357,7 +358,7 @@ public: std::shared_ptr<SfxItemSet> insertItemSet( const SfxItemSet& rSet ); // #i86923# - IStylePoolIteratorAccess* createIterator( bool bSkipUnusedItemSets, + std::unique_ptr<IStylePoolIteratorAccess> createIterator( bool bSkipUnusedItemSets, bool bSkipIgnorableItems ); }; @@ -432,10 +433,10 @@ std::shared_ptr<SfxItemSet> StylePoolImpl::insertItemSet( const SfxItemSet& rSet } // #i86923# -IStylePoolIteratorAccess* StylePoolImpl::createIterator( bool bSkipUnusedItemSets, +std::unique_ptr<IStylePoolIteratorAccess> StylePoolImpl::createIterator( bool bSkipUnusedItemSets, bool bSkipIgnorableItems ) { - return new Iterator( maRoot, bSkipUnusedItemSets, bSkipIgnorableItems ); + return o3tl::make_unique<Iterator>( maRoot, bSkipUnusedItemSets, bSkipIgnorableItems ); } // Ctor, Dtor and redirected methods of class StylePool, nearly inline ;-) @@ -448,7 +449,7 @@ std::shared_ptr<SfxItemSet> StylePool::insertItemSet( const SfxItemSet& rSet ) { return pImpl->insertItemSet( rSet ); } // #i86923# -IStylePoolIteratorAccess* StylePool::createIterator( const bool bSkipUnusedItemSets, +std::unique_ptr<IStylePoolIteratorAccess> StylePool::createIterator( const bool bSkipUnusedItemSets, const bool bSkipIgnorableItems ) { return pImpl->createIterator( bSkipUnusedItemSets, bSkipIgnorableItems ); diff --git a/sw/source/core/doc/swstylemanager.cxx b/sw/source/core/doc/swstylemanager.cxx index 40ca237164b8..0bef02b0ae08 100644 --- a/sw/source/core/doc/swstylemanager.cxx +++ b/sw/source/core/doc/swstylemanager.cxx @@ -43,7 +43,7 @@ public: void SwStyleCache::addCompletePool( StylePool& rPool ) { - IStylePoolIteratorAccess *pIter = rPool.createIterator(); + std::unique_ptr<IStylePoolIteratorAccess> pIter = rPool.createIterator(); std::shared_ptr<SfxItemSet> pStyle = pIter->getNext(); while( pStyle.get() ) { @@ -51,7 +51,6 @@ void SwStyleCache::addCompletePool( StylePool& rPool ) mMap[ aName ] = pStyle; pStyle = pIter->getNext(); } - delete pIter; } class SwStyleManager : public IStyleAccess @@ -140,7 +139,7 @@ void SwStyleManager::getAllStyles( std::vector<std::shared_ptr<SfxItemSet>> &rSt { StylePool& rAutoPool = eFamily == IStyleAccess::AUTO_STYLE_CHAR ? aAutoCharPool : aAutoParaPool; // setup <StylePool> iterator, which skips unused styles and ignorable items - IStylePoolIteratorAccess *pIter = rAutoPool.createIterator( true, true ); + std::unique_ptr<IStylePoolIteratorAccess> pIter = rAutoPool.createIterator( true, true ); std::shared_ptr<SfxItemSet> pStyle = pIter->getNext(); while( pStyle.get() ) { @@ -148,7 +147,6 @@ void SwStyleManager::getAllStyles( std::vector<std::shared_ptr<SfxItemSet>> &rSt pStyle = pIter->getNext(); } - delete pIter; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 9a9d407977494b405479b138a33fc6f8f1e2911d Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Mon Sep 10 15:31:24 2018 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Sep 11 08:17:31 2018 +0200 prevent crashes when running the global-analysis plugins Change-Id: Ib50583289afd6212d5d5aedd3d6b7ede75902052 Reviewed-on: https://gerrit.libreoffice.org/60277 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/compilerplugins/clang/plugin.cxx b/compilerplugins/clang/plugin.cxx index 1348c3f0f00f..84975c99107a 100644 --- a/compilerplugins/clang/plugin.cxx +++ b/compilerplugins/clang/plugin.cxx @@ -217,6 +217,10 @@ const FunctionDecl* Plugin::getParentFunctionDecl( const Stmt* stmt ) StringRef Plugin::getFileNameOfSpellingLoc(SourceLocation spellingLocation) const { + // prevent crashes when running the global-analysis plugins + if (!spellingLocation.isValid()) + return ""; + static enum { NOINIT, STDIN, GOOD } s_Mode(NOINIT); if (s_Mode == GOOD) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits