bridges/source/cpp_uno/shared/bridge.cxx | 2 bridges/source/jni_uno/jni_bridge.cxx | 4 bridges/source/jni_uno/jni_info.cxx | 6 - comphelper/source/misc/threadpool.cxx | 2 cppu/source/typelib/static_types.cxx | 2 cppu/source/typelib/typelib.cxx | 2 framework/source/accelerators/acceleratorconfiguration.cxx | 4 idlc/source/parser.y | 2 include/LibreOfficeKit/LibreOfficeKitInit.h | 6 - registry/source/regimpl.cxx | 6 - sal/osl/unx/file.cxx | 4 sal/osl/unx/pipe.cxx | 9 - sal/osl/unx/profile.cxx | 1 sal/osl/w32/file.cxx | 4 sal/rtl/alloc_arena.cxx | 2 sal/rtl/alloc_cache.cxx | 6 - sc/source/core/tool/compiler.cxx | 1 sc/source/filter/xml/xmldpimp.cxx | 6 - sc/source/filter/xml/xmldpimp.hxx | 3 sc/source/ui/view/viewdata.cxx | 2 sd/source/ui/animations/CustomAnimationPane.cxx | 2 sd/source/ui/unoidl/unosrch.cxx | 71 ++++--------- sfx2/source/control/itemdel.cxx | 2 soltools/cpp/_unix.c | 1 soltools/mkdepend/parse.c | 1 svtools/source/svhtml/htmlout.cxx | 2 sw/source/ui/index/cnttab.cxx | 9 - unoidl/source/legacyprovider.cxx | 32 +++-- unotest/source/cpp/officeconnection.cxx | 2 vcl/source/gdi/pdfwriter_impl.cxx | 1 30 files changed, 93 insertions(+), 104 deletions(-)
New commits: commit ba1e1727c238210b022741a710486964f28bb065 Author: Caolán McNamara <[email protected]> AuthorDate: Thu Jul 26 12:22:16 2018 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Fri Jul 27 09:32:19 2018 +0200 Related: rhbz#1602589 add comments to coverity annotations Change-Id: I88c941832a0d682ea4b6028c28edd48cf5df38f7 Reviewed-on: https://gerrit.libreoffice.org/58093 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> diff --git a/bridges/source/cpp_uno/shared/bridge.cxx b/bridges/source/cpp_uno/shared/bridge.cxx index 556350022e48..186d89aa1956 100644 --- a/bridges/source/cpp_uno/shared/bridge.cxx +++ b/bridges/source/cpp_uno/shared/bridge.cxx @@ -144,7 +144,7 @@ uno_Mapping * Bridge::createMapping( bool bExportCpp2Uno) { Bridge * bridge = new Bridge(pCppEnv, pUnoEnv, bExportCpp2Uno); - //coverity[leaked_storage] + // coverity[leaked_storage] - on purpose return bExportCpp2Uno ? &bridge->aCpp2Uno : &bridge->aUno2Cpp; } diff --git a/bridges/source/jni_uno/jni_bridge.cxx b/bridges/source/jni_uno/jni_bridge.cxx index 4a0d4b30af53..7f38d3221420 100644 --- a/bridges/source/jni_uno/jni_bridge.cxx +++ b/bridges/source/jni_uno/jni_bridge.cxx @@ -552,7 +552,7 @@ SAL_DLLPUBLIC_EXPORT void uno_ext_getMapping( uno_registerMapping( &mapping, Bridge_free, pFrom, &pTo->pExtEnv->aBase, nullptr ); - // coverity[leaked_storage] + // coverity[leaked_storage] - on purpose } else if ( from_env_typename == UNO_LB_UNO && to_env_typename == UNO_LB_JAVA ) { @@ -562,7 +562,7 @@ SAL_DLLPUBLIC_EXPORT void uno_ext_getMapping( uno_registerMapping( &mapping, Bridge_free, &pFrom->pExtEnv->aBase, pTo, nullptr ); - // coverity[leaked_storage] + // coverity[leaked_storage] - on purpose } } catch (const BridgeRuntimeError & err) diff --git a/bridges/source/jni_uno/jni_info.cxx b/bridges/source/jni_uno/jni_info.cxx index 9b43356856af..045ac44ee6be 100644 --- a/bridges/source/jni_uno/jni_info.cxx +++ b/bridges/source/jni_uno/jni_info.cxx @@ -103,7 +103,7 @@ JNI_interface_type_info::JNI_interface_type_info( typelib_InterfaceTypeDescription * td = reinterpret_cast< typelib_InterfaceTypeDescription * >( m_td.get() ); - // coverity [ctor_dtor_leak] + // coverity[ctor_dtor_leak] - on purpose m_methods.reset(new jmethodID[ td->nMapFunctionIndexToMemberIndex ]); sal_Int32 nMethodIndex = 0; typelib_TypeDescriptionReference ** ppMembers = td->ppMembers; @@ -288,7 +288,7 @@ JNI_compound_type_info::JNI_compound_type_info( td->aBase.pWeakRef, jni_info->m_RuntimeException_type.getTypeLibType() )) { - // coverity [ctor_dtor_leak] + // coverity[ctor_dtor_leak] - on purpose m_fields.reset(new jfieldID[ 2 ]); m_fields[ 0 ] = nullptr; // special Throwable.getMessage() // field Context @@ -860,7 +860,7 @@ JNI_info::JNI_info( { css::uno::TypeDescription XInterface_td( cppu::UnoType<css::uno::XInterface>::get()); - // coverity [ctor_dtor_leak] + // coverity[ctor_dtor_leak] - on purpose m_XInterface_type_info = new JNI_interface_type_info( jni, XInterface_td.get() ); } diff --git a/comphelper/source/misc/threadpool.cxx b/comphelper/source/misc/threadpool.cxx index 650541406a6a..fc9b2b3e5404 100644 --- a/comphelper/source/misc/threadpool.cxx +++ b/comphelper/source/misc/threadpool.cxx @@ -154,7 +154,7 @@ void ThreadPool::shutdownLocked(std::unique_lock<std::mutex>& aGuard) } assert( maTasks.empty() ); - // coverity[missing_lock] + // coverity[missing_lock] - on purpose mbTerminate = true; maTasksChanged.notify_all(); diff --git a/cppu/source/typelib/static_types.cxx b/cppu/source/typelib/static_types.cxx index eabd3950450f..2a3a5432b07f 100644 --- a/cppu/source/typelib/static_types.cxx +++ b/cppu/source/typelib/static_types.cxx @@ -439,7 +439,7 @@ void SAL_CALL typelib_static_interface_type_init( typelib_TypeDescriptionReference * pBaseType ) SAL_THROW_EXTERN_C() { - // coverity[callee_ptr_arith] + // coverity[callee_ptr_arith] - not a bug typelib_static_mi_interface_type_init( ppRef, pTypeName, pBaseType == nullptr ? 0 : 1, &pBaseType); } diff --git a/cppu/source/typelib/typelib.cxx b/cppu/source/typelib/typelib.cxx index 46238d5481b0..ec51f2128143 100644 --- a/cppu/source/typelib/typelib.cxx +++ b/cppu/source/typelib/typelib.cxx @@ -890,7 +890,7 @@ extern "C" void SAL_CALL typelib_typedescription_newInterface( typelib_TypeDescriptionReference ** ppMembers ) SAL_THROW_EXTERN_C() { - // coverity[callee_ptr_arith] + // coverity[callee_ptr_arith] - not a bug typelib_typedescription_newMIInterface( ppRet, pTypeName, 0, 0, 0, 0, 0, pBaseInterface == nullptr ? 0 : 1, &pBaseInterface, nMembers, ppMembers); diff --git a/framework/source/accelerators/acceleratorconfiguration.cxx b/framework/source/accelerators/acceleratorconfiguration.cxx index f8995ea47561..398b2ed5978f 100644 --- a/framework/source/accelerators/acceleratorconfiguration.cxx +++ b/framework/source/accelerators/acceleratorconfiguration.cxx @@ -1123,7 +1123,7 @@ void XCUBasedAcceleratorConfiguration::impl_ts_save(bool bPreferred) // take over all changes into the original container SolarMutexGuard g; - // coverity[check_after_deref] + // coverity[check_after_deref] - confusing but correct if (m_pPrimaryWriteCache) { m_aPrimaryReadCache.takeOver(*m_pPrimaryWriteCache); @@ -1161,7 +1161,7 @@ void XCUBasedAcceleratorConfiguration::impl_ts_save(bool bPreferred) // take over all changes into the original container SolarMutexGuard g; - // coverity[check_after_deref] + // coverity[check_after_deref] - confusing but correct if (m_pSecondaryWriteCache) { m_aSecondaryReadCache.takeOver(*m_pSecondaryWriteCache); diff --git a/idlc/source/parser.y b/idlc/source/parser.y index 9cc9e8d5ab5d..cb5f3ec470e3 100644 --- a/idlc/source/parser.y +++ b/idlc/source/parser.y @@ -2115,7 +2115,7 @@ at_least_one_scoped_name : } else { std::list< OString >* pScopedNames = new std::list< OString >; - // coverity [copy_paste_error] + // coverity[copy_paste_error] - this is not a cut and paste pScopedNames->push_back(*$1); $$ = pScopedNames; } diff --git a/include/LibreOfficeKit/LibreOfficeKitInit.h b/include/LibreOfficeKit/LibreOfficeKitInit.h index 687090a58b9f..a4befd405cb1 100644 --- a/include/LibreOfficeKit/LibreOfficeKitInit.h +++ b/include/LibreOfficeKit/LibreOfficeKitInit.h @@ -287,13 +287,13 @@ static LibreOfficeKit *lok_init_2( const char *install_path, const char *user_p } free( imp_lib ); // dlhandle is "leaked" - // coverity[leaked_storage] + // coverity[leaked_storage] - on purpose return pSym( install_path ); } free( imp_lib ); // dlhandle is "leaked" - // coverity[leaked_storage] + // coverity[leaked_storage] - on purpose return pSym2( install_path, user_profile_url ); #else return libreofficekit_hook_2( install_path, user_profile_url ); @@ -330,7 +330,7 @@ int lok_preinit( const char *install_path, const char *user_profile_url ) free( imp_lib ); // dlhandle is "leaked" - // coverity[leaked_storage] + // coverity[leaked_storage] - on purpose return pSym( install_path, user_profile_url ); } #endif diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx index 79279b1f3f90..1e24220f0ee9 100644 --- a/registry/source/regimpl.cxx +++ b/registry/source/regimpl.cxx @@ -324,8 +324,7 @@ void dumpType(typereg::Reader const & reader, OString const & indent) { printf( "%s parameter count: %u\n", indent.getStr(), static_cast< unsigned int >(reader.getMethodParameterCount(i))); - // coverity[tainted_data] cid#1215304 unhelpfully warns about an - // untrusted loop bound here: + // coverity[tainted_data] - cid#1215304 unhelpfully warns about untrusted loop bound for (sal_uInt16 j = 0; j < reader.getMethodParameterCount(i); ++j) { printf( @@ -366,8 +365,7 @@ void dumpType(typereg::Reader const & reader, OString const & indent) { printf( "%s exception count: %u\n", indent.getStr(), static_cast< unsigned int >(reader.getMethodExceptionCount(i))); - // coverity[tainted_data] cid#1215304 unhelpfully warns about an - // untrusted loop bound here: + // coverity[tainted_data] - cid#1215304 unhelpfully warns about untrusted loop bound for (sal_uInt16 j = 0; j < reader.getMethodExceptionCount(i); ++j) { printf( diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx index 0101bf6f8e36..94aa6e42fc8a 100644 --- a/sal/osl/unx/file.cxx +++ b/sal/osl/unx/file.cxx @@ -1134,10 +1134,10 @@ const off_t MAX_OFF_T = std::numeric_limits< off_t >::max(); namespace { -//coverity[result_independent_of_operands] +// coverity[result_independent_of_operands] - crossplatform requirement template<typename T> bool exceedsMaxOffT(T n) { return n > MAX_OFF_T; } -//coverity[result_independent_of_operands] +// coverity[result_independent_of_operands] - crossplatform requirement template<typename T> bool exceedsMinOffT(T n) { return n < std::numeric_limits<off_t>::min(); } diff --git a/sal/osl/unx/pipe.cxx b/sal/osl/unx/pipe.cxx index 0c68255dbb1d..eb03ff2280c5 100644 --- a/sal/osl/unx/pipe.cxx +++ b/sal/osl/unx/pipe.cxx @@ -287,10 +287,11 @@ oslPipe osl_psz_createPipe(const sal_Char *pszPipeName, oslPipeOptions Options, if (listen(pPipe->m_Socket, 5) < 0) { SAL_WARN("sal.osl.pipe", "listen() failed: " << strerror(errno)); - // coverity[toctou] cid#1255391 warns about unlink(name) after - // stat(name, &status) above, but the intervening call to bind makes - // those two clearly unrelated, as it would fail if name existed at - // that point in time: + // cid#1255391 warns about unlink(name) after stat(name, &status) + // above, but the intervening call to bind makes those two clearly + // unrelated, as it would fail if name existed at that point in + // time: + // coverity[toctou] - this is bogus unlink(name); /* remove filesystem entry */ close(pPipe->m_Socket); destroyPipeImpl(pPipe); diff --git a/sal/osl/w32/file.cxx b/sal/osl/w32/file.cxx index aed1b315bb9e..a63b58a1bdca 100644 --- a/sal/osl/w32/file.cxx +++ b/sal/osl/w32/file.cxx @@ -776,7 +776,7 @@ oslFileError SAL_CALL osl_closeFile(oslFileHandle Handle) namespace { -//coverity[result_independent_of_operands] +// coverity[result_independent_of_operands] - crossplatform requirement template<typename T> bool exceedsMaxSIZE_T(T n) { return n > std::numeric_limits< SIZE_T >::max(); } @@ -930,7 +930,7 @@ LONGLONG const g_limit_longlong = std::numeric_limits< LONGLONG >::max(); namespace { -//coverity[result_independent_of_operands] +// coverity[result_independent_of_operands] - crossplatform requirement template<typename T> bool exceedsMaxLONGLONG(T n) { return n > g_limit_longlong; } diff --git a/sal/rtl/alloc_arena.cxx b/sal/rtl/alloc_arena.cxx index 1cd06615d1a3..39e694e017d8 100644 --- a/sal/rtl/alloc_arena.cxx +++ b/sal/rtl/alloc_arena.cxx @@ -258,7 +258,7 @@ void rtl_arena_hash_rescale( rtl_arena_segment_type * next = curr->m_fnext; rtl_arena_segment_type ** head; - // coverity[negative_shift] + // coverity[negative_shift] - bogus head = &(arena->m_hash_table[RTL_ARENA_HASH_INDEX(arena, curr->m_addr)]); curr->m_fnext = (*head); (*head) = curr; diff --git a/sal/rtl/alloc_cache.cxx b/sal/rtl/alloc_cache.cxx index 38449ccfb795..41886c7ac235 100644 --- a/sal/rtl/alloc_cache.cxx +++ b/sal/rtl/alloc_cache.cxx @@ -817,7 +817,7 @@ void rtl_cache_deactivate(rtl_cache_type * cache) /* cleanup cpu layer */ if ((mag = cache->m_cpu_curr)) { - // coverity[missing_lock] + // coverity[missing_lock] - locking is fine cache->m_cpu_curr = nullptr; rtl_cache_magazine_clear (cache, mag); rtl_cache_free (mag_cache, mag); @@ -825,7 +825,7 @@ void rtl_cache_deactivate(rtl_cache_type * cache) if ((mag = cache->m_cpu_prev)) { - // coverity[missing_lock] + // coverity[missing_lock] - locking is fine cache->m_cpu_prev = nullptr; rtl_cache_magazine_clear (cache, mag); rtl_cache_free (mag_cache, mag); @@ -1267,7 +1267,7 @@ static void rtl_cache_depot_wsupdate( RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_depot_lock)); } } - // coverity[missing_unlock] + // coverity[missing_unlock] - locking is fine } /** diff --git a/sfx2/source/control/itemdel.cxx b/sfx2/source/control/itemdel.cxx index c6d53ef45936..d0555950dd39 100644 --- a/sfx2/source/control/itemdel.cxx +++ b/sfx2/source/control/itemdel.cxx @@ -77,7 +77,7 @@ void DeleteItemOnIdle(SfxPoolItem* pItem) DBG_ASSERT( 0 == pItem->GetRefCount(), "deleting item in use" ); SfxItemDisruptor_Impl *pDesruptor = new SfxItemDisruptor_Impl(pItem); pDesruptor->LaunchDeleteOnIdle(); - // coverity[leaked_storage] pDesruptor takes care of its own destruction at idle time + // coverity[leaked_storage] - pDesruptor takes care of its own destruction at idle time } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/svhtml/htmlout.cxx b/svtools/source/svhtml/htmlout.cxx index fb0a5b941a17..ae382dbb437c 100644 --- a/svtools/source/svhtml/htmlout.cxx +++ b/svtools/source/svhtml/htmlout.cxx @@ -465,7 +465,7 @@ static OString lcl_ConvertCharToHTML( sal_uInt32 c, // If the character could not be converted to the destination // character set, the UNICODE character is exported as character // entity. - // coverity[callee_ptr_arith] + // coverity[callee_ptr_arith] - its ok nLen = lcl_FlushContext(rContext, cBuffer, nFlags); sal_Char *pBuffer = cBuffer; while( nLen-- ) diff --git a/unoidl/source/legacyprovider.cxx b/unoidl/source/legacyprovider.cxx index a7eb47fc7a88..eb9462c733f2 100644 --- a/unoidl/source/legacyprovider.cxx +++ b/unoidl/source/legacyprovider.cxx @@ -259,9 +259,9 @@ rtl::Reference< Entity > readEntity( { sal_uInt16 m = reader.getMethodExceptionCount(k); - // coverity[tainted_data] cid#1213376 - // unhelpfully warns about an untrusted loop - // bound here: + // cid#1213376 unhelpfully warns about an + // untrusted loop bound here: + // coverity[tainted_data] - trusted data source for (sal_uInt16 l = 0; l != m; ++l) { getExcs.push_back( reader.getMethodExceptionTypeName(k, l). @@ -273,9 +273,9 @@ rtl::Reference< Entity > readEntity( { sal_uInt16 m = reader.getMethodExceptionCount(k); - // coverity[tainted_data] cid#1213376 - // unhelpfully warns about an untrusted loop - // bound here: + // cid#1213376 unhelpfully warns about an + // untrusted loop bound here: + // coverity[tainted_data] - trusted data source for (sal_uInt16 l = 0; l != m; ++l) { setExcs.push_back( reader.getMethodExceptionTypeName(k, l). @@ -309,8 +309,9 @@ rtl::Reference< Entity > readEntity( std::vector< InterfaceTypeEntity::Method::Parameter > params; sal_uInt16 m = reader.getMethodParameterCount(j); - // coverity[tainted_data] cid#1213376 unhelpfully warns - // about an untrusted loop bound here: + // cid#1213376 unhelpfully warns about an untrusted loop + // bound here: + // coverity[tainted_data] - trusted data source for (sal_uInt16 k = 0; k != m; ++k) { RTParamMode mode = reader.getMethodParameterFlags(j, k); InterfaceTypeEntity::Method::Parameter::Direction dir; @@ -342,8 +343,9 @@ rtl::Reference< Entity > readEntity( } std::vector< OUString > excs; m = reader.getMethodExceptionCount(j); - // coverity[tainted_data] cid#1213376 unhelpfully warns - // about an untrusted loop bound here: + // cid#1213376 unhelpfully warns about an untrusted loop + // bound here: + // coverity[tainted_data] - trusted data source for (sal_uInt16 k = 0; k != m; ++k) { excs.push_back( reader.getMethodExceptionTypeName(j, k).replace( @@ -607,8 +609,9 @@ rtl::Reference< Entity > readEntity( SingleInterfaceBasedServiceEntity::Constructor:: Parameter > params; sal_uInt16 m = reader.getMethodParameterCount(j); - // coverity[tainted_data] cid#1213376 unhelpfully warns - // about an untrusted loop bound here: + // cid#1213376 unhelpfully warns about an untrusted + // loop bound here: + // coverity[tainted_data] - trusted data source for (sal_uInt16 k = 0; k != m; ++k) { RTParamMode mode = reader.getMethodParameterFlags(j, k); @@ -647,8 +650,9 @@ rtl::Reference< Entity > readEntity( } std::vector< OUString > excs; m = reader.getMethodExceptionCount(j); - // coverity[tainted_data] cid#1213376 unhelpfully warns - // about an untrusted loop bound here: + // cid#1213376 unhelpfully warns about an untrusted + // loop bound here: + // coverity[tainted_data] - trusted data source for (sal_uInt16 k = 0; k != m; ++k) { excs.push_back( reader.getMethodExceptionTypeName(j, k).replace( diff --git a/unotest/source/cpp/officeconnection.cxx b/unotest/source/cpp/officeconnection.cxx index a82471e3b921..c85ad7b72e5f 100644 --- a/unotest/source/cpp/officeconnection.cxx +++ b/unotest/source/cpp/officeconnection.cxx @@ -78,7 +78,7 @@ void OfficeConnection::setUp() { { envs = &argEnv.pData; } - // coverity[callee_ptr_arith] + // coverity[callee_ptr_arith] - arith is fine CPPUNIT_ASSERT_EQUAL( osl_Process_E_None, osl_executeProcess( commit 877dd9e9d1c1774817fa96f62adda98d5bce0ce8 Author: Caolán McNamara <[email protected]> AuthorDate: Thu Jul 26 14:49:17 2018 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Fri Jul 27 09:31:31 2018 +0200 Related: rhbz#1602589 fix leaked_storage no logic change intended Change-Id: Ic4d54965033e518195ef8e76ddec7feca14970c2 Reviewed-on: https://gerrit.libreoffice.org/58125 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> diff --git a/sd/source/ui/unoidl/unosrch.cxx b/sd/source/ui/unoidl/unosrch.cxx index c46753cfc4b9..7233d37d3b77 100644 --- a/sd/source/ui/unoidl/unosrch.cxx +++ b/sd/source/ui/unoidl/unosrch.cxx @@ -54,11 +54,10 @@ class SearchContext_impl { uno::Reference< drawing::XShapes > mxShapes; sal_Int32 mnIndex; - SearchContext_impl* mpParent; public: - SearchContext_impl( uno::Reference< drawing::XShapes > const & xShapes, SearchContext_impl* pParent = nullptr ) - : mxShapes( xShapes ), mnIndex( -1 ), mpParent( pParent ) {} + SearchContext_impl(uno::Reference<drawing::XShapes> const& xShapes) + : mxShapes( xShapes ), mnIndex( -1 ) {} uno::Reference< drawing::XShape > firstShape() { @@ -76,8 +75,6 @@ public: } return xShape; } - - SearchContext_impl* getParent() const { return mpParent; } }; /* ================================================================= */ @@ -111,7 +108,7 @@ sal_Int32 SAL_CALL SdUnoSearchReplaceShape::replaceAll( const uno::Reference< ut uno::Reference< drawing::XShapes > xShapes; uno::Reference< drawing::XShape > xShape; - SearchContext_impl* pContext = nullptr; + std::vector<SearchContext_impl> aContexts; if(mpPage) { uno::Reference< drawing::XDrawPage > xPage( mpPage ); @@ -120,8 +117,8 @@ sal_Int32 SAL_CALL SdUnoSearchReplaceShape::replaceAll( const uno::Reference< ut if( xShapes.is() && (xShapes->getCount() > 0) ) { - pContext = new SearchContext_impl( xShapes ); - xShape = pContext->firstShape(); + aContexts.push_back(SearchContext_impl(xShapes)); + xShape = aContexts.back().firstShape(); } else { @@ -152,34 +149,24 @@ sal_Int32 SAL_CALL SdUnoSearchReplaceShape::replaceAll( const uno::Reference< ut uno::Reference< drawing::XShapes > xGroupShape( xShape, uno::UNO_QUERY ); if( xGroupShape.is() && ( xGroupShape->getCount() > 0 ) ) { - pContext = new SearchContext_impl( xGroupShape, pContext ); - xShape = pContext->firstShape(); + aContexts.push_back(SearchContext_impl(xGroupShape)); + xShape = aContexts.back().firstShape(); } else { - if( pContext ) - xShape = pContext->nextShape(); + if (!aContexts.empty()) + xShape = aContexts.back().nextShape(); else xShape = nullptr; } // test parent contexts for next shape if none // is found in the current context - while( pContext && !xShape.is() ) + while (!aContexts.empty() && !xShape.is()) { - if( pContext->getParent() ) - { - SearchContext_impl* pOldContext = pContext; - pContext = pContext->getParent(); - delete pOldContext; - xShape = pContext->nextShape(); - } - else - { - delete pContext; - pContext = nullptr; - xShape = nullptr; - } + aContexts.pop_back(); + if (!aContexts.empty()) + xShape = aContexts.back().nextShape(); } } @@ -208,7 +195,7 @@ uno::Reference< css::container::XIndexAccess > SAL_CALL SdUnoSearchReplaceShape: uno::Reference< drawing::XShapes > xShapes; uno::Reference< drawing::XShape > xShape; - SearchContext_impl* pContext = nullptr; + std::vector<SearchContext_impl> aContexts; if(mpPage) { uno::Reference< drawing::XDrawPage > xPage( mpPage ); @@ -216,8 +203,8 @@ uno::Reference< css::container::XIndexAccess > SAL_CALL SdUnoSearchReplaceShape: if( xShapes.is() && xShapes->getCount() > 0 ) { - pContext = new SearchContext_impl( xShapes ); - xShape = pContext->firstShape(); + aContexts.push_back(SearchContext_impl(xShapes)); + xShape = aContexts.back().firstShape(); } else { @@ -257,34 +244,24 @@ uno::Reference< css::container::XIndexAccess > SAL_CALL SdUnoSearchReplaceShape: if( xGroupShape.is() && xGroupShape->getCount() > 0 ) { - pContext = new SearchContext_impl( xGroupShape, pContext ); - xShape = pContext->firstShape(); + aContexts.push_back(SearchContext_impl(xGroupShape)); + xShape = aContexts.back().firstShape(); } else { - if( pContext ) - xShape = pContext->nextShape(); + if (!aContexts.empty()) + xShape = aContexts.back().nextShape(); else xShape = nullptr; } // test parent contexts for next shape if none // is found in the current context - while( pContext && !xShape.is() ) + while (!aContexts.empty() && !xShape.is()) { - if( pContext->getParent() ) - { - SearchContext_impl* pOldContext = pContext; - pContext = pContext->getParent(); - delete pOldContext; - xShape = pContext->nextShape(); - } - else - { - delete pContext; - pContext = nullptr; - xShape = nullptr; - } + aContexts.pop_back(); + if (!aContexts.empty()) + xShape = aContexts.back().nextShape(); } } commit 8d11d68c25baaab08f30d4e0a24753ac43ab90b0 Author: Caolán McNamara <[email protected]> AuthorDate: Thu Jul 26 12:39:28 2018 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Fri Jul 27 09:30:59 2018 +0200 Related: rhbz#1602589 silence leaked_storage Change-Id: I21cc4af40429fa3ef4284d6c0ea592b05bf36620 Reviewed-on: https://gerrit.libreoffice.org/58121 Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx index 3df800e908d4..c24579c5ccc1 100644 --- a/sw/source/ui/index/cnttab.cxx +++ b/sw/source/ui/index/cnttab.cxx @@ -4033,8 +4033,9 @@ bool SwEntryBrowseBox::SaveModified() pController = m_xCheckController.get(); bVal = static_cast< ::svt::CheckBoxCellController*>(pController)->GetCheckBox().IsChecked(); } - AutoMarkEntry* pEntry = (nRow >= m_Entries.size()) ? new AutoMarkEntry - : m_Entries[nRow].get(); + const bool bAddEntry = nRow >= m_Entries.size(); + std::unique_ptr<AutoMarkEntry> xNewEntry(bAddEntry ? new AutoMarkEntry : nullptr); + AutoMarkEntry* pEntry = bAddEntry ? xNewEntry.get() : m_Entries[nRow].get(); switch(nCol) { case ITEM_SEARCH : pEntry->sSearch = sNew; break; @@ -4045,9 +4046,9 @@ bool SwEntryBrowseBox::SaveModified() case ITEM_CASE : pEntry->bCase = bVal; break; case ITEM_WORDONLY : pEntry->bWord = bVal; break; } - if (nRow >= m_Entries.size()) + if (bAddEntry) { - m_Entries.push_back(std::unique_ptr<AutoMarkEntry>(pEntry)); + m_Entries.push_back(std::move(xNewEntry)); RowInserted(nRow, 1, true, true); if(nCol < ITEM_WORDONLY) { commit 2d6d7171cdf3c50c71e4af271e4ce689ce7482ef Author: Caolán McNamara <[email protected]> AuthorDate: Thu Jul 26 12:10:40 2018 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Fri Jul 27 09:28:29 2018 +0200 Related: rhbz#1602589 silence leaked_storage Change-Id: Ib489ebf55d3a18d2af6f34b3f6128231d6d7758c Reviewed-on: https://gerrit.libreoffice.org/58090 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> diff --git a/sal/osl/unx/profile.cxx b/sal/osl/unx/profile.cxx index e1992da2416e..d103c4573d0a 100644 --- a/sal/osl/unx/profile.cxx +++ b/sal/osl/unx/profile.cxx @@ -181,6 +181,7 @@ static oslProfile osl_psz_openProfile(const sal_Char *pszProfileName, oslProfile if (pProfile->m_pFile == nullptr) closeFileImpl(pFile,pProfile->m_Flags); + // coverity[leaked_storage] - pFile is not leaked return pProfile; } diff --git a/soltools/cpp/_unix.c b/soltools/cpp/_unix.c index 7d15d57ed45a..2ee9215524a2 100644 --- a/soltools/cpp/_unix.c +++ b/soltools/cpp/_unix.c @@ -204,6 +204,7 @@ void error(FATAL, "Can't open output file %s", argv[optind + 1]); dup2(fdo, 1); + // coverity[leaked_handle] - on purpose } includelist[NINCLUDE - 1].always = 0; includelist[NINCLUDE - 1].file = dp; diff --git a/soltools/mkdepend/parse.c b/soltools/mkdepend/parse.c index 8aa05547bbe7..23aa67849b49 100644 --- a/soltools/mkdepend/parse.c +++ b/soltools/mkdepend/parse.c @@ -158,6 +158,7 @@ int find_includes(struct filepointer *filep, struct inclist *file, struct inclis break; } } + // coverity[leaked_storage] - on purpose return -1; } commit 7a937660201d48d5e94971aebd81ece98f529f57 Author: Caolán McNamara <[email protected]> AuthorDate: Thu Jul 26 12:00:36 2018 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Fri Jul 27 09:27:44 2018 +0200 Related: rhbz#1602589 silence coverity copy_paste_error Change-Id: Idca4bfaaa9f127eae87ae879e2131aed747ce4b3 Reviewed-on: https://gerrit.libreoffice.org/58089 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index b7e62c52e3df..5a9de437077e 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -5707,6 +5707,7 @@ bool ScCompiler::HandleTableRef() default: ; // nothing } + // coverity[copy_paste_error] - this is correct, aStart in both aDBRange uses if (aColRange.aStart.Row() != aDBRange.aStart.Row() || aColRange.aEnd.Row() != aDBRange.aStart.Row()) aRange = ScRange( ScAddress::INITIALIZE_INVALID); else diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index 4f0ccf24f0b3..1d215f1a2908 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -178,6 +178,7 @@ ScPositionHelper::getNearestByIndex(index_type nIndex) const } auto posLB = std::prev(posUB); + // coverity[copy_paste_error] - posUB is correct if (posUB == mData.end()) { return *posLB; @@ -208,6 +209,7 @@ ScPositionHelper::getNearestByPosition(long nPos) const } auto posLB = std::prev(posUB); + // coverity[copy_paste_error] - posUB is correct if (posUB == mData.end()) { return *posLB; diff --git a/sd/source/ui/animations/CustomAnimationPane.cxx b/sd/source/ui/animations/CustomAnimationPane.cxx index eea562a53d7f..50bf2231a20b 100644 --- a/sd/source/ui/animations/CustomAnimationPane.cxx +++ b/sd/source/ui/animations/CustomAnimationPane.cxx @@ -2343,6 +2343,7 @@ void CustomAnimationPane::moveSelection( bool bUp ) CustomAnimationEffectPtr pEffect = (*aIter++); EffectSequence::iterator aUpEffectPos( pSequence->find( pEffect ) ); + // coverity[copy_paste_error] - this is correct, checking if it exists if( aUpEffectPos != rEffectSequence.end() ) { EffectSequence::iterator aInsertPos( rEffectSequence.erase( aUpEffectPos ) ); @@ -2373,6 +2374,7 @@ void CustomAnimationPane::moveSelection( bool bUp ) CustomAnimationEffectPtr pEffect = (*aIter++); EffectSequence::iterator aDownEffectPos( pSequence->find( pEffect ) ); + // coverity[copy_paste_error] - this is correct, checking if it exists if( aDownEffectPos != rEffectSequence.end() ) { EffectSequence::iterator aInsertPos( rEffectSequence.erase( aDownEffectPos ) ); diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 3071fb1371f4..b7b5546acafc 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -6287,6 +6287,7 @@ void PDFWriterImpl::drawRelief( SalLayout& rLayout, const OUString& rText, bool aTextLineColor = COL_WHITE; if( aOverlineColor == COL_BLACK ) aOverlineColor = COL_WHITE; + // coverity[copy_paste_error] - aReliefColor depending on aTextColor is correct if( aTextColor == COL_WHITE ) aReliefColor = COL_BLACK; commit e41b7bc4cc2376b8fafeab0ef8fed388b0b9d7ae Author: Caolán McNamara <[email protected]> AuthorDate: Thu Jul 26 13:45:33 2018 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Fri Jul 27 09:26:52 2018 +0200 ScDPObject is only needed in endFastElement Change-Id: I8e1a7897777111c225e42ebcf81e67face6b29b9 Reviewed-on: https://gerrit.libreoffice.org/58114 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> diff --git a/sc/source/filter/xml/xmldpimp.cxx b/sc/source/filter/xml/xmldpimp.cxx index ecfae1ab28a2..f1c1e96bf309 100644 --- a/sc/source/filter/xml/xmldpimp.cxx +++ b/sc/source/filter/xml/xmldpimp.cxx @@ -96,7 +96,6 @@ ScXMLDataPilotTableContext::ScXMLDataPilotTableContext( ScXMLImport& rImport, const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList ) : ScXMLImportContext( rImport ), pDoc(GetScImport().GetDocument()), - pDPObject(new ScDPObject(pDoc)), pDPSave(new ScDPSaveData()), pDPDimSaveData(nullptr), sDataPilotTableName(), @@ -320,7 +319,7 @@ ScDPOutputGeometry::FieldType toFieldType(sheet::DataPilotFieldOrientation nOrie } -void ScXMLDataPilotTableContext::SetButtons() +void ScXMLDataPilotTableContext::SetButtons(ScDPObject* pDPObject) { ScDPOutputGeometry aGeometry(aTargetRangeAddress, bShowFilter); aGeometry.setColumnFieldCount(mnColFieldCount); @@ -452,6 +451,7 @@ void SAL_CALL ScXMLDataPilotTableContext::endFastElement( sal_Int32 /*nElement*/ if (!bTargetRangeAddress) return; + ScDPObject* pDPObject(new ScDPObject(pDoc)); pDPObject->SetName(sDataPilotTableName); pDPObject->SetTag(sApplicationData); pDPObject->SetOutRange(aTargetRangeAddress); @@ -539,7 +539,7 @@ void SAL_CALL ScXMLDataPilotTableContext::endFastElement( sal_Int32 /*nElement*/ pDPCollection->InsertNewTable(pDPObject); - SetButtons(); + SetButtons(pDPObject); } void ScXMLDataPilotTableContext::SetGrandTotal( diff --git a/sc/source/filter/xml/xmldpimp.hxx b/sc/source/filter/xml/xmldpimp.hxx index 536a90d06557..b99dd73d38eb 100644 --- a/sc/source/filter/xml/xmldpimp.hxx +++ b/sc/source/filter/xml/xmldpimp.hxx @@ -71,7 +71,6 @@ class ScXMLDataPilotTableContext : public ScXMLImportContext GrandTotalItem(); }; ScDocument* pDoc; - ScDPObject* pDPObject; std::unique_ptr<ScDPSaveData> pDPSave; std::unique_ptr<ScDPDimensionSaveData> pDPDimSaveData; GrandTotalItem maRowGrandTotal; @@ -139,7 +138,7 @@ public: void AddDimension(ScDPSaveDimension* pDim); void AddGroupDim(const ScDPSaveNumGroupDimension& aNumGroupDim); void AddGroupDim(const ScDPSaveGroupDimension& aGroupDim); - void SetButtons(); + void SetButtons(ScDPObject* pDPObject); void SetSelectedPage( const OUString& rDimName, const OUString& rSelected ); }; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
