[poppler] poppler/SignatureHandler.cc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri May 10 21:44:03 UTC 2019


 poppler/SignatureHandler.cc |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

New commits:
commit eaeac5c7dba6f53acef3f0be6b226facecfc5f28
Author: Albert Astals Cid <aacid at kde.org>
Date:   Fri May 10 23:28:02 2019 +0200

    Fix crash on signature handling
    
    Since we only call NSS_Init once, we should only call NSS_Shutdown once.
    
    Do it via atexit
    
    Fixes issue #766

diff --git a/poppler/SignatureHandler.cc b/poppler/SignatureHandler.cc
index c8258403..0afc1593 100644
--- a/poppler/SignatureHandler.cc
+++ b/poppler/SignatureHandler.cc
@@ -26,6 +26,13 @@
 #include <dirent.h>
 #include <Error.h>
 
+static void shutdownNss()
+{
+  if (NSS_Shutdown() != SECSuccess) {
+    fprintf(stderr, "NSS_Shutdown failed: %s\n", PR_ErrorToString(PORT_GetError(), PR_LANGUAGE_I_DEFAULT));
+  }
+}
+
 unsigned int SignatureHandler::digestLength(SECOidTag digestAlgId)
 {
   switch(digestAlgId){
@@ -232,6 +239,8 @@ void SignatureHandler::setNSSDir(const GooString &nssDir)
 
   setNssDirCalled = true;
 
+  atexit(shutdownNss);
+
   bool initSuccess = false;
   if (nssDir.getLength() > 0) {
     initSuccess = (NSS_Init(nssDir.c_str()) == SECSuccess);
@@ -305,9 +314,6 @@ SignatureHandler::~SignatureHandler()
     HASH_Destroy(hash_context);
 
   free(temp_certs);
-
-  if (NSS_Shutdown()!=SECSuccess)
-    fprintf(stderr, "Detail: %s\n", PR_ErrorToString(PORT_GetError(), PR_LANGUAGE_I_DEFAULT));
 }
 
 NSSCMSMessage *SignatureHandler::CMS_MessageCreate(SECItem * cms_item)


More information about the poppler mailing list