summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--package/inc/ZipPackage.hxx3
-rw-r--r--package/source/zippackage/ZipPackage.cxx12
2 files changed, 7 insertions, 8 deletions
diff --git a/package/inc/ZipPackage.hxx b/package/inc/ZipPackage.hxx
index 2856e42665eb..6a3ac01a88bd 100644
--- a/package/inc/ZipPackage.hxx
+++ b/package/inc/ZipPackage.hxx
@@ -36,6 +36,7 @@
#include <osl/file.h>
#include <mutexholder.hxx>
#include <vector>
+#include <memory>
class ZipOutputStream;
class ZipPackageFolder;
@@ -97,7 +98,7 @@ protected:
css::uno::Reference < css::io::XSeekable > m_xContentSeek;
const css::uno::Reference < css::uno::XComponentContext > m_xContext;
- ZipFile *m_pZipFile;
+ std::unique_ptr<ZipFile> m_pZipFile;
bool isLocalFile() const;
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index 026e1ed6da6b..cb2e618a62ee 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -69,7 +69,6 @@
#include "com/sun/star/io/XAsyncOutputMonitor.hpp"
#include <cstring>
-#include <memory>
#include <vector>
#include <comphelper/processfactory.hxx>
@@ -80,6 +79,7 @@
#include <comphelper/sequenceashashmap.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <comphelper/sequence.hxx>
+#include <o3tl/make_unique.hxx>
using namespace std;
using namespace osl;
@@ -156,14 +156,12 @@ ZipPackage::ZipPackage ( const uno::Reference < XComponentContext > &xContext )
, m_bAllowRemoveOnInsert( true )
, m_eMode ( e_IMode_None )
, m_xContext( xContext )
-, m_pZipFile( nullptr )
{
m_xRootFolder = new ZipPackageFolder( m_xContext, m_nFormat, m_bAllowRemoveOnInsert );
}
ZipPackage::~ZipPackage()
{
- delete m_pZipFile;
}
bool ZipPackage::isLocalFile() const
@@ -734,7 +732,7 @@ void SAL_CALL ZipPackage::initialize( const uno::Sequence< Any >& aArguments )
OUString message;
try
{
- m_pZipFile = new ZipFile ( m_xContentStream, m_xContext, true, m_bForceRecovery );
+ m_pZipFile = o3tl::make_unique<ZipFile>(m_xContentStream, m_xContext, true, m_bForceRecovery);
getZipFileContents();
}
catch ( IOException & e )
@@ -749,14 +747,14 @@ void SAL_CALL ZipPackage::initialize( const uno::Sequence< Any >& aArguments )
}
catch ( Exception & )
{
- if( m_pZipFile ) { delete m_pZipFile; m_pZipFile = nullptr; }
+ m_pZipFile.reset();
throw;
}
if ( bBadZipFile )
{
// clean up the memory, and tell the UCB about the error
- if( m_pZipFile ) { delete m_pZipFile; m_pZipFile = nullptr; }
+ m_pZipFile.reset();
throw css::packages::zip::ZipIOException (
THROW_WHERE "Bad Zip File, " + message,
@@ -1104,7 +1102,7 @@ void ZipPackage::ConnectTo( const uno::Reference< io::XInputStream >& xInStream
if ( m_pZipFile )
m_pZipFile->setInputStream( m_xContentStream );
else
- m_pZipFile = new ZipFile ( m_xContentStream, m_xContext, false );
+ m_pZipFile = o3tl::make_unique<ZipFile>(m_xContentStream, m_xContext, false);
}
namespace