[Libreoffice-commits] core.git: package/source
Luboš Luňák (via logerrit)
logerrit at kemper.freedesktop.org
Mon Jun 10 09:16:51 UTC 2019
package/source/zippackage/ZipPackageFolder.cxx | 30 ++++++++++++++-----------
1 file changed, 17 insertions(+), 13 deletions(-)
New commits:
commit aa809b35b487b594166d7aa7ecccf221ac1054e1
Author: Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Fri Jun 7 10:55:24 2019 +0200
Commit: Luboš Luňák <l.lunak at collabora.com>
CommitDate: Mon Jun 10 11:16:13 2019 +0200
bail out immediately if saving part of a zip package fails
There's no point in continuing to write other parts if the final result
will be a failure anyway. Moreover this avoids an assert
in ZipOutputStream::writeLOC() if writing of the previous part resulted
in an error (e.g. ZipException because of broken zip CRC for the stream)
that skipped calling ZipOutputStream::rawCloseEntry().
Change-Id: I5095b97a31cac9befcab5e82bd8cda2dfa53c7f7
Reviewed-on: https://gerrit.libreoffice.org/73646
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak at collabora.com>
diff --git a/package/source/zippackage/ZipPackageFolder.cxx b/package/source/zippackage/ZipPackageFolder.cxx
index 1aaaedcd3d89..bd7512a19fc8 100644
--- a/package/source/zippackage/ZipPackageFolder.cxx
+++ b/package/source/zippackage/ZipPackageFolder.cxx
@@ -287,8 +287,6 @@ void ZipPackageFolder::saveContents(
sal_Int32 nPBKDF2IterationCount,
const rtlRandomPool &rRandomPool ) const
{
- bool bWritingFailed = false;
-
if ( maContents.empty() && !rPath.isEmpty() && m_nFormat != embed::StorageFormats::OFOPXML )
{
// it is an empty subfolder, use workaround to store it
@@ -305,11 +303,11 @@ void ZipPackageFolder::saveContents(
}
catch ( ZipException& )
{
- bWritingFailed = true;
+ throw uno::RuntimeException( THROW_WHERE );
}
catch ( IOException& )
{
- bWritingFailed = true;
+ throw uno::RuntimeException( THROW_WHERE );
}
}
@@ -322,8 +320,11 @@ void ZipPackageFolder::saveContents(
if ( aIter != maContents.end() && !(*aIter).second->bFolder )
{
bMimeTypeStreamStored = true;
- bWritingFailed = !aIter->second->pStream->saveChild(
- rPath + aIter->first, rManList, rZipOut, rEncryptionKey, nPBKDF2IterationCount, rRandomPool );
+ if( !aIter->second->pStream->saveChild(
+ rPath + aIter->first, rManList, rZipOut, rEncryptionKey, nPBKDF2IterationCount, rRandomPool ))
+ {
+ throw uno::RuntimeException( THROW_WHERE );
+ }
}
}
@@ -335,19 +336,22 @@ void ZipPackageFolder::saveContents(
{
if (rInfo.bFolder)
{
- bWritingFailed = !rInfo.pFolder->saveChild(
- rPath + rShortName, rManList, rZipOut, rEncryptionKey, nPBKDF2IterationCount, rRandomPool );
+ if( !rInfo.pFolder->saveChild(
+ rPath + rShortName, rManList, rZipOut, rEncryptionKey, nPBKDF2IterationCount, rRandomPool ))
+ {
+ throw uno::RuntimeException( THROW_WHERE );
+ }
}
else
{
- bWritingFailed = !rInfo.pStream->saveChild(
- rPath + rShortName, rManList, rZipOut, rEncryptionKey, nPBKDF2IterationCount, rRandomPool );
+ if( !rInfo.pStream->saveChild(
+ rPath + rShortName, rManList, rZipOut, rEncryptionKey, nPBKDF2IterationCount, rRandomPool ))
+ {
+ throw uno::RuntimeException( THROW_WHERE );
+ }
}
}
}
-
- if( bWritingFailed )
- throw uno::RuntimeException(THROW_WHERE );
}
sal_Int64 SAL_CALL ZipPackageFolder::getSomething( const uno::Sequence< sal_Int8 >& aIdentifier )
More information about the Libreoffice-commits
mailing list