diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2013-09-05 15:28:17 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2013-09-05 15:41:51 +0200 |
commit | a8986c2c6537116ae834fcbee12b1f1a0a418590 (patch) | |
tree | 0ae1844127cad091d68b298c284b11ac43ed536f /vcl/source | |
parent | d73c039fa5353f0b96026bed4a0da31d9a41d2c7 (diff) |
CID#736586: fix memory leaks
Change-Id: I02a10b8b0d18334ce693d0cead0b81d34b4eeeac
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index d2d3e7e446dc..9b720c2c4de3 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -73,6 +73,8 @@ #include "cppuhelper/implbase1.hxx" +#include <boost/scoped_array.hpp> + #if !defined(ANDROID) && !defined(IOS) // NSS header files for PDF signing support #include "nss.h" @@ -6003,26 +6005,24 @@ bool PDFWriterImpl::finalizeSignature() HASH_Begin(hc.get()); - char *buffer = new char[m_nSignatureContentOffset + 1]; + boost::scoped_array<char> buffer(new char[m_nSignatureContentOffset + 1]); sal_uInt64 bytesRead; //FIXME: Check if SHA1 is calculated from the correct byterange - CHECK_RETURN( (osl_File_E_None == osl_readFile( m_aFile, buffer, m_nSignatureContentOffset - 1 , &bytesRead ) ) ); + CHECK_RETURN( (osl_File_E_None == osl_readFile( m_aFile, buffer.get(), m_nSignatureContentOffset - 1 , &bytesRead ) ) ); if (bytesRead != (sal_uInt64)m_nSignatureContentOffset - 1) SAL_WARN("vcl.gdi", "PDF Signing: First buffer read failed!"); - HASH_Update(hc.get(), reinterpret_cast<const unsigned char*>(buffer), bytesRead); - delete[] buffer; + HASH_Update(hc.get(), reinterpret_cast<const unsigned char*>(buffer.get()), bytesRead); CHECK_RETURN( (osl_File_E_None == osl_setFilePos( m_aFile, osl_Pos_Absolut, m_nSignatureContentOffset + MAX_SIGNATURE_CONTENT_LENGTH + 1) ) ); - buffer = new char[nLastByteRangeNo + 1]; - CHECK_RETURN( (osl_File_E_None == osl_readFile( m_aFile, buffer, nLastByteRangeNo, &bytesRead ) ) ); + buffer.reset(new char[nLastByteRangeNo + 1]); + CHECK_RETURN( (osl_File_E_None == osl_readFile( m_aFile, buffer.get(), nLastByteRangeNo, &bytesRead ) ) ); if (bytesRead != (sal_uInt64) nLastByteRangeNo) SAL_WARN("vcl.gdi", "PDF Signing: Second buffer read failed!"); - HASH_Update(hc.get(), reinterpret_cast<const unsigned char*>(buffer), bytesRead); - delete[] buffer; + HASH_Update(hc.get(), reinterpret_cast<const unsigned char*>(buffer.get()), bytesRead); SECItem digest; unsigned char hash[SHA1_LENGTH]; |