basctl/source/basicide/bastype2.cxx | 3 ++- binaryurp/source/reader.cxx | 6 ++++-- codemaker/source/javamaker/javatype.cxx | 6 ++++-- package/source/zippackage/ZipPackageStream.cxx | 8 +++++--- registry/source/regimpl.cxx | 3 ++- sd/source/ui/tools/SdGlobalResourceContainer.cxx | 5 ++++- ucb/source/ucp/webdav-neon/DAVSessionFactory.cxx | 3 ++- 7 files changed, 23 insertions(+), 11 deletions(-)
New commits: commit bb209f2f53edc1b0d268d561e0c12bf93e83fb41 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Sep 11 09:42:35 2018 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Sep 11 15:18:26 2018 +0200 Revert "clang bugprone-unused-return-value" comment from sberg: aren't these changes broken in general, when the called function may throw an exception before it takes ownership of the passed-in pointer? So revert, except for (a) PlainTextFilterDetect::detect, which was definitely a leak (b) SwCursor::FindAll, where unique_ptr was being unnecessarily used This reverts commit 7764ae70b04058a64a3999529e98d1115ba59d1c. Change-Id: I555e651b44e245b031729013d2ce88d26e8a357e Reviewed-on: https://gerrit.libreoffice.org/60301 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/basctl/source/basicide/bastype2.cxx b/basctl/source/basicide/bastype2.cxx index d8fe8efdc59a..5997980df2ea 100644 --- a/basctl/source/basicide/bastype2.cxx +++ b/basctl/source/basicide/bastype2.cxx @@ -701,8 +701,9 @@ SvTreeListEntry* TreeListBox::AddEntry( { SvTreeListEntry* p = InsertEntry( rText, rImage, rImage, pParent, bChildrenOnDemand, TREELIST_APPEND, - aUserData.release() + aUserData.get() ); + aUserData.release(); return p; } diff --git a/binaryurp/source/reader.cxx b/binaryurp/source/reader.cxx index c40aeadea7df..fa5e91be704e 100644 --- a/binaryurp/source/reader.cxx +++ b/binaryurp/source/reader.cxx @@ -335,8 +335,9 @@ void Reader::readMessage(Unmarshal & unmarshal) { bridge_->incrementActiveCalls(); } uno_threadpool_putJob( - bridge_->getThreadPool(), tid.getHandle(), req.release(), &request, + bridge_->getThreadPool(), tid.getHandle(), req.get(), &request, !synchronous); + req.release(); } } @@ -442,8 +443,9 @@ void Reader::readReplyMessage(Unmarshal & unmarshal, sal_uInt8 flags1) { std::unique_ptr< IncomingReply > resp( new IncomingReply(exc, ret, outArgs)); uno_threadpool_putJob( - bridge_->getThreadPool(), tid.getHandle(), resp.release(), nullptr, + bridge_->getThreadPool(), tid.getHandle(), resp.get(), nullptr, false); + resp.release(); break; } case OutgoingRequest::KIND_REQUEST_CHANGE: diff --git a/codemaker/source/javamaker/javatype.cxx b/codemaker/source/javamaker/javatype.cxx index 944f1a0aca9f..5530392b278b 100644 --- a/codemaker/source/javamaker/javatype.cxx +++ b/codemaker/source/javamaker/javatype.cxx @@ -764,7 +764,8 @@ void handleEnumType( std::unique_ptr< ClassFile::Code > blockCode(cf->newCode()); blockCode->instrGetstatic(className, pair.second, classDescriptor); blockCode->instrAreturn(); - blocks.push_back(blockCode.release()); + blocks.push_back(blockCode.get()); + blockCode.release(); } code->instrTableswitch(defCode.get(), min, blocks); for (ClassFile::Code *p : blocks) @@ -782,7 +783,8 @@ void handleEnumType( std::unique_ptr< ClassFile::Code > blockCode(cf->newCode()); blockCode->instrGetstatic(className, pair.second, classDescriptor); blockCode->instrAreturn(); - blocks.emplace_back(pair.first, blockCode.release()); + blocks.emplace_back(pair.first, blockCode.get()); + blockCode.release(); } code->instrLookupswitch(defCode.get(), blocks); for (const std::pair< sal_Int32, ClassFile::Code * >& pair : blocks) diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx index 5e62b8bf1aff..5fe4d0ef80c5 100644 --- a/package/source/zippackage/ZipPackageStream.cxx +++ b/package/source/zippackage/ZipPackageStream.cxx @@ -727,9 +727,10 @@ bool ZipPackageStream::saveChild( if ( m_bRawStream ) xStream->skipBytes( m_nMagicalHackPos ); - // the entry is provided to the ZipOutputStream that will delete it - ZipOutputStream::setEntry(pAutoTempEntry.release()); + ZipOutputStream::setEntry(pTempEntry); rZipOut.writeLOC(pTempEntry); + // the entry is provided to the ZipOutputStream that will delete it + pAutoTempEntry.release(); uno::Sequence < sal_Int8 > aSeq ( n_ConstBufferSize ); sal_Int32 nLength; @@ -796,8 +797,9 @@ bool ZipPackageStream::saveChild( try { + ZipOutputStream::setEntry(pTempEntry); // the entry is provided to the ZipOutputStream that will delete it - ZipOutputStream::setEntry(pAutoTempEntry.release()); + pAutoTempEntry.release(); if (pTempEntry->nMethod == STORED) { diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx index ac065a3e65a3..a7647b9d512f 100644 --- a/registry/source/regimpl.cxx +++ b/registry/source/regimpl.cxx @@ -700,7 +700,8 @@ RegError ORegistry::openKey(RegKeyHandle hKey, const OUString& keyName, } std::unique_ptr< ORegKey > p(new ORegKey(path, this)); - i = m_openKeyTable.insert(std::make_pair(path, p.release())).first; + i = m_openKeyTable.insert(std::make_pair(path, p.get())).first; + p.release(); } else { i->second->acquire(); } diff --git a/sd/source/ui/tools/SdGlobalResourceContainer.cxx b/sd/source/ui/tools/SdGlobalResourceContainer.cxx index 26ec1df742db..b6408cdf04be 100644 --- a/sd/source/ui/tools/SdGlobalResourceContainer.cxx +++ b/sd/source/ui/tools/SdGlobalResourceContainer.cxx @@ -99,7 +99,7 @@ void SdGlobalResourceContainer::AddResource ( mpImpl->maResources.end(), pResource.get()); if (iResource == mpImpl->maResources.end()) - mpImpl->maResources.push_back(pResource.release()); + mpImpl->maResources.push_back(pResource.get()); else { // Because the given resource is a unique_ptr it is highly unlikely @@ -107,6 +107,9 @@ void SdGlobalResourceContainer::AddResource ( SAL_WARN ( "sd.tools", "SdGlobalResourceContainer:AddResource(): Resource added twice."); } + // We can not put the unique_ptr into the vector so we release the + // unique_ptr and document that we take ownership explicitly. + pResource.release(); } void SdGlobalResourceContainer::AddResource ( diff --git a/ucb/source/ucp/webdav-neon/DAVSessionFactory.cxx b/ucb/source/ucp/webdav-neon/DAVSessionFactory.cxx index ba0df6f79bfe..13eda808ee31 100644 --- a/ucb/source/ucp/webdav-neon/DAVSessionFactory.cxx +++ b/ucb/source/ucp/webdav-neon/DAVSessionFactory.cxx @@ -70,8 +70,9 @@ rtl::Reference< DAVSession > DAVSessionFactory::createDAVSession( std::unique_ptr< DAVSession > xElement( new NeonSession( this, inUri, rFlags, *m_xProxyDecider.get() ) ); - aIt = m_aMap.emplace( inUri, xElement.release() ).first; + aIt = m_aMap.emplace( inUri, xElement.get() ).first; aIt->second->m_aContainerIt = aIt; + xElement.release(); return aIt->second; } else if ( osl_atomic_increment( &aIt->second->m_nRefCount ) > 1 ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits