summaryrefslogtreecommitdiff
path: root/xmlsecurity
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2021-03-09 09:54:16 +0100
committerStephan Bergmann <sbergman@redhat.com>2021-03-09 14:23:45 +0100
commitbbcf235753dc87ef6bc6652a77239513110e2d9e (patch)
tree0636b306f11ec31554ff4618547230de9c877977 /xmlsecurity
parent5e8c0e2556eebfee7b2d75403cbf5cee6642e644 (diff)
loplugin:refcounting (clang-cl)
Change-Id: I91189ebd902b70e2fbe42fe8cc09b8677af1a5fb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112194 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'xmlsecurity')
-rw-r--r--xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx29
-rw-r--r--xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx6
2 files changed, 15 insertions, 20 deletions
diff --git a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx
index c21158695d70..ff6bc2f319e4 100644
--- a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx
+++ b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx
@@ -44,6 +44,7 @@
#include <comphelper/windowserrorstring.hxx>
#include <sal/log.hxx>
#include <rtl/locale.h>
+#include <rtl/ref.hxx>
#include <osl/nlsupport.h>
#include <osl/process.h>
#include <o3tl/char16_t2wchar_t.hxx>
@@ -57,7 +58,7 @@ using ::com::sun::star::lang::XSingleServiceFactory ;
using ::com::sun::star::xml::crypto::XSecurityEnvironment ;
using ::com::sun::star::security::XCertificate ;
-static X509Certificate_MSCryptImpl* MswcryCertContextToXCert( PCCERT_CONTEXT cert ) ;
+static rtl::Reference<X509Certificate_MSCryptImpl> MswcryCertContextToXCert( PCCERT_CONTEXT cert ) ;
namespace {
@@ -299,8 +300,8 @@ static BOOL WINAPI cert_enum_system_store_callback(const void *pvSystemStore,
uno::Sequence< uno::Reference < XCertificate > > SecurityEnvironment_MSCryptImpl::getPersonalCertificates()
{
sal_Int32 length ;
- X509Certificate_MSCryptImpl* xcert ;
- std::vector< X509Certificate_MSCryptImpl* > certsList ;
+ rtl::Reference<X509Certificate_MSCryptImpl> xcert ;
+ std::vector< rtl::Reference<X509Certificate_MSCryptImpl> > certsList ;
PCCERT_CONTEXT pCertContext = nullptr;
//firstly, we try to find private keys in given key store.
@@ -309,7 +310,7 @@ uno::Sequence< uno::Reference < XCertificate > > SecurityEnvironment_MSCryptImpl
while (pCertContext)
{
xcert = MswcryCertContextToXCert( pCertContext ) ;
- if( xcert != nullptr )
+ if( xcert.is() )
certsList.push_back( xcert ) ;
pCertContext = CertEnumCertificatesInStore( m_hKeyStore, pCertContext );
}
@@ -347,7 +348,7 @@ uno::Sequence< uno::Reference < XCertificate > > SecurityEnvironment_MSCryptImpl
// then TODO : Check the personal cert is valid or not.
xcert = MswcryCertContextToXCert( pCertContext ) ;
- if( xcert != nullptr )
+ if( xcert.is() )
certsList.push_back( xcert ) ;
pCertContext = CertEnumCertificatesInStore( hSystemKeyStore, pCertContext );
}
@@ -375,7 +376,7 @@ uno::Sequence< uno::Reference < XCertificate > > SecurityEnvironment_MSCryptImpl
uno::Reference< XCertificate > SecurityEnvironment_MSCryptImpl::getCertificate( const OUString& issuerName, const uno::Sequence< sal_Int8 >& serialNumber ) {
unsigned int i ;
- X509Certificate_MSCryptImpl *xcert = nullptr ;
+ rtl::Reference<X509Certificate_MSCryptImpl> xcert ;
PCCERT_CONTEXT pCertContext = nullptr ;
HCERTSTORE hCertStore = nullptr ;
CRYPT_INTEGER_BLOB cryptSerialNumber ;
@@ -561,8 +562,6 @@ uno::Reference< XCertificate > SecurityEnvironment_MSCryptImpl::getCertificate(
if( pCertContext != nullptr ) {
xcert = MswcryCertContextToXCert(pCertContext);
CertFreeCertificateContext(pCertContext);
- } else {
- xcert = nullptr ;
}
return xcert ;
@@ -660,7 +659,7 @@ uno::Sequence< uno::Reference < XCertificate > > SecurityEnvironment_MSCryptImpl
{
PCCERT_CONTEXT pCertInChain ;
PCERT_SIMPLE_CHAIN pCertChain ;
- X509Certificate_MSCryptImpl* pCert ;
+ rtl::Reference<X509Certificate_MSCryptImpl> pCert ;
pCertChain = pChainContext->rgpChain[0] ;
if( pCertChain->cElement ) {
@@ -674,7 +673,7 @@ uno::Sequence< uno::Reference < XCertificate > > SecurityEnvironment_MSCryptImpl
if( pCertInChain != nullptr ) {
pCert = MswcryCertContextToXCert( pCertInChain ) ;
- if( pCert != nullptr )
+ if( pCert.is() )
xCertChain[i] = pCert ;
}
}
@@ -692,13 +691,11 @@ uno::Sequence< uno::Reference < XCertificate > > SecurityEnvironment_MSCryptImpl
}
uno::Reference< XCertificate > SecurityEnvironment_MSCryptImpl::createCertificateFromRaw( const uno::Sequence< sal_Int8 >& rawCertificate ) {
- X509Certificate_MSCryptImpl* xcert ;
+ rtl::Reference<X509Certificate_MSCryptImpl> xcert ;
if( rawCertificate.getLength() > 0 ) {
xcert = new X509Certificate_MSCryptImpl() ;
xcert->setRawCert( rawCertificate ) ;
- } else {
- xcert = nullptr ;
}
return xcert ;
@@ -970,15 +967,13 @@ bool SecurityEnvironment_MSCryptImpl::defaultEnabled() {
return m_bEnableDefault ;
}
-static X509Certificate_MSCryptImpl* MswcryCertContextToXCert( PCCERT_CONTEXT cert )
+static rtl::Reference<X509Certificate_MSCryptImpl> MswcryCertContextToXCert( PCCERT_CONTEXT cert )
{
- X509Certificate_MSCryptImpl* xcert ;
+ rtl::Reference<X509Certificate_MSCryptImpl> xcert ;
if( cert != nullptr ) {
xcert = new X509Certificate_MSCryptImpl() ;
xcert->setMswcryCert( cert ) ;
- } else {
- xcert = nullptr ;
}
return xcert ;
diff --git a/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx
index d9d45f5e7062..ce65672987c5 100644
--- a/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx
+++ b/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx
@@ -32,6 +32,7 @@
#include "oid.hxx"
#include <rtl/locale.h>
+#include <rtl/ref.hxx>
#include <osl/nlsupport.h>
#include <osl/process.h>
#include <o3tl/char16_t2wchar_t.hxx>
@@ -359,7 +360,7 @@ css::uno::Sequence< sal_Int8 > SAL_CALL X509Certificate_MSCryptImpl::getSubjectU
css::uno::Sequence< css::uno::Reference< css::security::XCertificateExtension > > SAL_CALL X509Certificate_MSCryptImpl::getExtensions() {
if( m_pCertContext != nullptr && m_pCertContext->pCertInfo != nullptr && m_pCertContext->pCertInfo->cExtension != 0 ) {
- CertificateExtension_XmlSecImpl* xExtn ;
+ rtl::Reference<CertificateExtension_XmlSecImpl> xExtn ;
Sequence< Reference< XCertificateExtension > > xExtns( m_pCertContext->pCertInfo->cExtension ) ;
for( unsigned int i = 0; i < m_pCertContext->pCertInfo->cExtension; i++ ) {
@@ -386,9 +387,8 @@ css::uno::Sequence< css::uno::Reference< css::security::XCertificateExtension >
css::uno::Reference< css::security::XCertificateExtension > SAL_CALL X509Certificate_MSCryptImpl::findCertificateExtension( const css::uno::Sequence< sal_Int8 >& /*oid*/ ) {
if( m_pCertContext != nullptr && m_pCertContext->pCertInfo != nullptr && m_pCertContext->pCertInfo->cExtension != 0 ) {
- CertificateExtension_XmlSecImpl* xExtn ;
+ rtl::Reference<CertificateExtension_XmlSecImpl> xExtn ;
- xExtn = nullptr ;
for( unsigned int i = 0; i < m_pCertContext->pCertInfo->cExtension; i++ ) {
CERT_EXTENSION* pExtn = &( m_pCertContext->pCertInfo->rgExtension[i] ) ;