summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2014-09-12 14:09:34 +0100
committerMichael Meeks <michael.meeks@collabora.com>2014-09-15 13:21:16 +0100
commite8a398bd165e1b90a69c453e0465e28de08b3cf8 (patch)
treeb52269141f399f3ba41ca8d47585f8a0c7362c56 /vcl
parent9701b6753d98d89da1170d1f847e4e5a47f813a7 (diff)
fdo#66701 - don't double destroy the HASH when PDF signing.
Accidentally introduced in d73c039fa it seems. Change-Id: I846314ebca3a24520492887d4d9027f812cfb32f
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx18
1 files changed, 14 insertions, 4 deletions
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 89355ad6422d..8f6a7e9be048 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -5951,6 +5951,17 @@ char *PDFSigningPKCS7PasswordCallback(PK11SlotInfo * /*slot*/, PRBool /*retry*/,
return (char *)arg;
}
+namespace {
+ class HashContextScope {
+ HASHContext *mpPtr;
+ public:
+ HashContextScope(HASHContext *pPtr) : mpPtr(pPtr) {}
+ ~HashContextScope() { clear(); }
+ void clear() { if (mpPtr) { HASH_Destroy(mpPtr); } mpPtr = NULL; }
+ HASHContext *get() { return mpPtr; }
+ };
+}
+
bool PDFWriterImpl::finalizeSignature()
{
@@ -6000,9 +6011,8 @@ bool PDFWriterImpl::finalizeSignature()
// Prepare buffer and calculate PDF file digest
CHECK_RETURN( (osl_File_E_None == osl_setFilePos( m_aFile, osl_Pos_Absolut, 0) ) );
- boost::scoped_ptr<HASHContext> hc(HASH_Create(HASH_AlgSHA1));
-
- if (!hc)
+ HashContextScope hc(HASH_Create(HASH_AlgSHA1));
+ if (!hc.get())
{
SAL_WARN("vcl.gdi", "PDF Signing: SHA1 HASH_Create failed!");
return false;
@@ -6033,7 +6043,7 @@ bool PDFWriterImpl::finalizeSignature()
unsigned char hash[SHA1_LENGTH];
digest.data = hash;
HASH_End(hc.get(), digest.data, &digest.len, SHA1_LENGTH);
- HASH_Destroy(hc.get());
+ hc.clear();
const char *pass = OUStringToOString( m_aContext.SignPassword, RTL_TEXTENCODING_UTF8 ).getStr();