[Libreoffice-commits] core.git: xmlsecurity/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Oct 18 07:14:46 UTC 2018


 xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx |   17 +++++-----
 1 file changed, 10 insertions(+), 7 deletions(-)

New commits:
commit 181a1b36ac728e3a43e054496ceb53fd3315abdb
Author:     Miklos Vajna <vmiklos at collabora.co.uk>
AuthorDate: Wed Oct 17 21:47:36 2018 +0200
Commit:     Miklos Vajna <vmiklos at collabora.co.uk>
CommitDate: Thu Oct 18 09:13:53 2018 +0200

    xmlsecurity: avoid repeated manual calls to PORT_FreeArena()
    
    Change-Id: Id62a894b08e6221c858304d7cb198a5a3f0cbd43
    Reviewed-on: https://gerrit.libreoffice.org/61893
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx
index ef68129496d6..86d68c522ed7 100644
--- a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx
+++ b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx
@@ -57,6 +57,14 @@ using ::com::sun::star::lang::XSingleServiceFactory ;
 using ::com::sun::star::xml::crypto::XSecurityEnvironment ;
 using ::com::sun::star::security::XCertificate ;
 
+namespace std
+{
+template <> struct default_delete<PRArenaPool>
+{
+    void operator()(PRArenaPool* ptr) { PORT_FreeArena(ptr, PR_FALSE); }
+};
+}
+
 static X509Certificate_NssImpl* NssCertToXCert( CERTCertificate* cert ) ;
 static X509Certificate_NssImpl* NssPrivKeyToXCert( SECKEYPrivateKey* ) ;
 
@@ -329,9 +337,7 @@ Reference< XCertificate > SecurityEnvironment_NssImpl::getCertificate( const OUS
         CERTName* nmIssuer ;
         char* chIssuer ;
         SECItem* derIssuer ;
-        PRArenaPool* arena ;
-
-        arena = PORT_NewArena( DER_DEFAULT_CHUNKSIZE ) ;
+        std::unique_ptr<PRArenaPool> arena(PORT_NewArena(DER_DEFAULT_CHUNKSIZE));
         if( arena == nullptr )
             throw RuntimeException() ;
 
@@ -341,15 +347,13 @@ Reference< XCertificate > SecurityEnvironment_NssImpl::getCertificate( const OUS
         nmIssuer = CERT_AsciiToName( chIssuer ) ;
         if( nmIssuer == nullptr ) {
             PL_strfree( chIssuer ) ;
-            PORT_FreeArena( arena, PR_FALSE ) ;
             return nullptr; // no need for exception cf. i40394
         }
 
-        derIssuer = SEC_ASN1EncodeItem( arena, nullptr, static_cast<void*>(nmIssuer), SEC_ASN1_GET( CERT_NameTemplate ) ) ;
+        derIssuer = SEC_ASN1EncodeItem( arena.get(), nullptr, static_cast<void*>(nmIssuer), SEC_ASN1_GET( CERT_NameTemplate ) ) ;
         if( derIssuer == nullptr ) {
             PL_strfree( chIssuer ) ;
             CERT_DestroyName( nmIssuer ) ;
-            PORT_FreeArena( arena, PR_FALSE ) ;
             throw RuntimeException() ;
         }
 
@@ -372,7 +376,6 @@ Reference< XCertificate > SecurityEnvironment_NssImpl::getCertificate( const OUS
         CERT_DestroyName( nmIssuer ) ;
         //SECITEM_FreeItem( derIssuer, PR_FALSE ) ;
         CERT_DestroyCertificate( cert ) ;
-        PORT_FreeArena( arena, PR_FALSE ) ;
     } else {
         xcert = nullptr ;
     }


More information about the Libreoffice-commits mailing list