Kaydet (Commit) ea053226 authored tarafından Michael Meeks's avatar Michael Meeks

fdo#66701 - don't double destroy the HASH when PDF signing.

Accidentally introduced in d73c039f it seems.

Change-Id: I846314ebca3a24520492887d4d9027f812cfb32f
üst 2ff2e254
......@@ -5945,6 +5945,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()
{
......@@ -5994,9 +6005,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;
......@@ -6027,7 +6037,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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment