From 74f884d48ed27e1ce861620a57802ad156a86d15 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 7 Nov 2023 12:50:17 +0200 Subject: new loplugin:fieldcast new plugin to look for class fields that are always cast to some subtype, which indicates that they should probably just be declared to be that subtype. Perform one of the suggested improvements in xmlsecurity/ Change-Id: Ia68df422c37f05cbcf9c02ba5d0853f8eca4f120 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159063 Tested-by: Jenkins Reviewed-by: Noel Grandin --- .../source/xmlsec/nss/securityenvironment_nssimpl.cxx | 12 ++++++------ .../source/xmlsec/nss/securityenvironment_nssimpl.hxx | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'xmlsecurity') diff --git a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx index 32ece48520d6..2ab5b011e2c7 100644 --- a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx +++ b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx @@ -344,14 +344,15 @@ Reference< XCertificate > SecurityEnvironment_NssImpl::getCertificate( const OUS } Sequence< Reference < XCertificate > > SecurityEnvironment_NssImpl::buildCertificatePath( const Reference< XCertificate >& begin ) { - // Remember the signing certificate. - m_xSigningCertificate = begin; - const X509Certificate_NssImpl* xcert = dynamic_cast(begin.get()); + X509Certificate_NssImpl* xcert = dynamic_cast(begin.get()); if( xcert == nullptr ) { throw RuntimeException() ; } + // Remember the signing certificate. + m_xSigningCertificate = xcert; + const CERTCertificate* cert = xcert->getNssCert() ; if (!cert) return {}; @@ -796,10 +797,9 @@ xmlSecKeysMngrPtr SecurityEnvironment_NssImpl::createKeysManager() { throw RuntimeException(); // Adopt the private key of the signing certificate, if it has any. - if (auto pCertificate - = dynamic_cast(m_xSigningCertificate.get())) + if (m_xSigningCertificate) { - SECKEYPrivateKey* pPrivateKey = SECKEY_CopyPrivateKey(pCertificate->getPrivateKey()); + SECKEYPrivateKey* pPrivateKey = SECKEY_CopyPrivateKey(m_xSigningCertificate->getPrivateKey()); if (pPrivateKey) { xmlSecKeyDataPtr pKeyData = xmlSecNssPKIAdoptKey(pPrivateKey, nullptr); diff --git a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.hxx b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.hxx index 253d3ea1f4e3..c0e469899852 100644 --- a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.hxx +++ b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.hxx @@ -52,7 +52,7 @@ private: std::vector< PK11SlotInfo* > m_Slots; /// The last used certificate which has the private key for signing. - css::uno::Reference m_xSigningCertificate; + rtl::Reference m_xSigningCertificate; std::mutex m_mutex; -- cgit