CID#1078782: fix memory leak
Change-Id: I4a98e68b5f74de787e28925e2e55de96f1cb980e
This commit is contained in:
@@ -5993,7 +5993,7 @@ bool PDFWriterImpl::finalizeSignature()
|
||||
// Prepare buffer and calculate PDF file digest
|
||||
CHECK_RETURN( (osl_File_E_None == osl_setFilePos( m_aFile, osl_Pos_Absolut, 0) ) );
|
||||
|
||||
HASHContext *hc = HASH_Create(HASH_AlgSHA1);
|
||||
boost::scoped_ptr<HASHContext> hc(HASH_Create(HASH_AlgSHA1));
|
||||
|
||||
if (!hc)
|
||||
{
|
||||
@@ -6001,7 +6001,7 @@ bool PDFWriterImpl::finalizeSignature()
|
||||
return false;
|
||||
}
|
||||
|
||||
HASH_Begin(hc);
|
||||
HASH_Begin(hc.get());
|
||||
|
||||
char *buffer = new char[m_nSignatureContentOffset + 1];
|
||||
sal_uInt64 bytesRead;
|
||||
@@ -6012,7 +6012,7 @@ bool PDFWriterImpl::finalizeSignature()
|
||||
if (bytesRead != (sal_uInt64)m_nSignatureContentOffset - 1)
|
||||
SAL_WARN("vcl.gdi", "PDF Signing: First buffer read failed!");
|
||||
|
||||
HASH_Update(hc, reinterpret_cast<const unsigned char*>(buffer), bytesRead);
|
||||
HASH_Update(hc.get(), reinterpret_cast<const unsigned char*>(buffer), bytesRead);
|
||||
delete[] buffer;
|
||||
|
||||
CHECK_RETURN( (osl_File_E_None == osl_setFilePos( m_aFile, osl_Pos_Absolut, m_nSignatureContentOffset + MAX_SIGNATURE_CONTENT_LENGTH + 1) ) );
|
||||
@@ -6021,14 +6021,14 @@ bool PDFWriterImpl::finalizeSignature()
|
||||
if (bytesRead != (sal_uInt64) nLastByteRangeNo)
|
||||
SAL_WARN("vcl.gdi", "PDF Signing: Second buffer read failed!");
|
||||
|
||||
HASH_Update(hc, reinterpret_cast<const unsigned char*>(buffer), bytesRead);
|
||||
HASH_Update(hc.get(), reinterpret_cast<const unsigned char*>(buffer), bytesRead);
|
||||
delete[] buffer;
|
||||
|
||||
SECItem digest;
|
||||
unsigned char hash[SHA1_LENGTH];
|
||||
digest.data = hash;
|
||||
HASH_End(hc, digest.data, &digest.len, SHA1_LENGTH);
|
||||
HASH_Destroy(hc);
|
||||
HASH_End(hc.get(), digest.data, &digest.len, SHA1_LENGTH);
|
||||
HASH_Destroy(hc.get());
|
||||
|
||||
const char *pass = OUStringToOString( m_aContext.SignPassword, RTL_TEXTENCODING_UTF8 ).getStr();
|
||||
|
||||
|
Reference in New Issue
Block a user