avoid possible leak on exception
Change-Id: Id3c16e5fedc5e57c8daccafa25bdb2fbbd0131b0
This commit is contained in:
@@ -1117,6 +1117,33 @@ void ZipPackage::ConnectTo( const uno::Reference< io::XInputStream >& xInStream
|
|||||||
m_pZipFile = new ZipFile ( m_xContentStream, m_xContext, false );
|
m_pZipFile = new ZipFile ( m_xContentStream, m_xContext, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
class RandomPool
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
rtlRandomPool m_aRandomPool;
|
||||||
|
public:
|
||||||
|
RandomPool()
|
||||||
|
{
|
||||||
|
// Get a random number generator and seed it with current timestamp
|
||||||
|
TimeValue aTime;
|
||||||
|
osl_getSystemTime( &aTime );
|
||||||
|
m_aRandomPool = rtl_random_createPool ();
|
||||||
|
rtl_random_addBytes (m_aRandomPool, &aTime, 8);
|
||||||
|
}
|
||||||
|
rtlRandomPool get()
|
||||||
|
{
|
||||||
|
return m_aRandomPool;
|
||||||
|
}
|
||||||
|
~RandomPool()
|
||||||
|
{
|
||||||
|
// Clean up random pool memory
|
||||||
|
rtl_random_destroyPool(m_aRandomPool);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
uno::Reference< io::XInputStream > ZipPackage::writeTempFile()
|
uno::Reference< io::XInputStream > ZipPackage::writeTempFile()
|
||||||
{
|
{
|
||||||
// In case the target local file does not exist or empty
|
// In case the target local file does not exist or empty
|
||||||
@@ -1218,20 +1245,15 @@ uno::Reference< io::XInputStream > ZipPackage::writeTempFile()
|
|||||||
aManList.push_back( aPropSeq );
|
aManList.push_back( aPropSeq );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get a random number generator and seed it with current timestamp
|
{
|
||||||
// This will be used to generate random salt and initialisation vectors
|
// This will be used to generate random salt and initialisation vectors
|
||||||
// for encrypted streams
|
// for encrypted streams
|
||||||
TimeValue aTime;
|
RandomPool aRandomPool;
|
||||||
osl_getSystemTime( &aTime );
|
|
||||||
rtlRandomPool aRandomPool = rtl_random_createPool ();
|
|
||||||
rtl_random_addBytes ( aRandomPool, &aTime, 8 );
|
|
||||||
|
|
||||||
// call saveContents ( it will recursively save sub-directories
|
// call saveContents ( it will recursively save sub-directories
|
||||||
OUString aEmptyString;
|
OUString aEmptyString;
|
||||||
m_pRootFolder->saveContents( aEmptyString, aManList, aZipOut, GetEncryptionKey(), aRandomPool );
|
m_pRootFolder->saveContents(aEmptyString, aManList, aZipOut, GetEncryptionKey(), aRandomPool.get());
|
||||||
|
}
|
||||||
// Clean up random pool memory
|
|
||||||
rtl_random_destroyPool ( aRandomPool );
|
|
||||||
|
|
||||||
if( m_nFormat == embed::StorageFormats::PACKAGE )
|
if( m_nFormat == embed::StorageFormats::PACKAGE )
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user