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

Noel (via logerrit) logerrit at kemper.freedesktop.org
Fri Feb 19 06:36:05 UTC 2021


 xmloff/source/transform/ChartOASISTContext.cxx                |    2 
 xmloff/source/transform/ChartOOoTContext.cxx                  |    2 
 xmloff/source/transform/ChartPlotAreaOASISTContext.cxx        |    4 
 xmloff/source/transform/ChartPlotAreaOOoTContext.cxx          |    2 
 xmloff/source/transform/ControlOASISTContext.cxx              |    2 
 xmloff/source/transform/CreateElemTContext.cxx                |    2 
 xmloff/source/transform/DlgOASISTContext.cxx                  |    2 
 xmloff/source/transform/DocumentTContext.cxx                  |    2 
 xmloff/source/transform/EventOASISTContext.cxx                |    2 
 xmloff/source/transform/EventOOoTContext.cxx                  |    2 
 xmloff/source/transform/FormPropOASISTContext.cxx             |    2 
 xmloff/source/transform/FormPropOOoTContext.cxx               |    2 
 xmloff/source/transform/FrameOOoTContext.cxx                  |    4 
 xmloff/source/transform/MergeElemTContext.cxx                 |    2 
 xmloff/source/transform/MutableAttrList.cxx                   |    5 
 xmloff/source/transform/MutableAttrList.hxx                   |    3 
 xmloff/source/transform/NotesTContext.cxx                     |    2 
 xmloff/source/transform/OOo2Oasis.cxx                         |    6 
 xmloff/source/transform/Oasis2OOo.cxx                         |    6 
 xmloff/source/transform/PersAttrListTContext.cxx              |    2 
 xmloff/source/transform/ProcAddAttrTContext.cxx               |    2 
 xmloff/source/transform/RenameElemTContext.cxx                |    2 
 xmloff/source/transform/StyleOASISTContext.cxx                |    4 
 xmloff/source/transform/StyleOOoTContext.cxx                  |    2 
 xmloff/source/transform/TransformerBase.cxx                   |    6 
 xmlsecurity/source/gpg/SecurityEnvironment.cxx                |   12 -
 xmlsecurity/source/helper/xmlsignaturehelper.cxx              |    4 
 xmlsecurity/source/helper/xsecctl.cxx                         |   28 ++--
 xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx |   64 +++-------
 xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.hxx |    5 
 xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.cxx     |    4 
 xmlsecurity/source/xmlsec/xmldocumentwrapper_xmlsecimpl.cxx   |   11 -
 32 files changed, 90 insertions(+), 110 deletions(-)

New commits:
commit 75894d5c6afd3f4d206b50c529d83db9c1f8232d
Author:     Noel <noel.grandin at collabora.co.uk>
AuthorDate: Thu Feb 18 15:06:44 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Feb 19 07:35:28 2021 +0100

    loplugin:refcounting in xmloff
    
    Change-Id: I739aa5914359edc4fdfdc341b09718ddbb7c04e7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111121
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/xmloff/source/transform/ChartOASISTContext.cxx b/xmloff/source/transform/ChartOASISTContext.cxx
index fbe2c70726da..314de40318d2 100644
--- a/xmloff/source/transform/ChartOASISTContext.cxx
+++ b/xmloff/source/transform/ChartOASISTContext.cxx
@@ -50,7 +50,7 @@ void XMLChartOASISTransformerContext::StartElement(
 
     OUString aAddInName;
     Reference< XAttributeList > xAttrList( rAttrList );
-    XMLMutableAttributeList *pMutableAttrList = nullptr;
+    rtl::Reference<XMLMutableAttributeList> pMutableAttrList;
     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     for( sal_Int16 i=0; i < nAttrCount; i++ )
     {
diff --git a/xmloff/source/transform/ChartOOoTContext.cxx b/xmloff/source/transform/ChartOOoTContext.cxx
index dcbd495031cd..781cb3764c8e 100644
--- a/xmloff/source/transform/ChartOOoTContext.cxx
+++ b/xmloff/source/transform/ChartOOoTContext.cxx
@@ -51,7 +51,7 @@ void XMLChartOOoTransformerContext::StartElement(
     sal_Int16 nClassName = -1;
     OUString aAddInName;
     Reference< XAttributeList > xAttrList( rAttrList );
-    XMLMutableAttributeList *pMutableAttrList = nullptr;
+    rtl::Reference<XMLMutableAttributeList> pMutableAttrList;
     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     for( sal_Int16 i=0; i < nAttrCount; i++ )
     {
diff --git a/xmloff/source/transform/ChartPlotAreaOASISTContext.cxx b/xmloff/source/transform/ChartPlotAreaOASISTContext.cxx
index b14457047411..b8603f62fd59 100644
--- a/xmloff/source/transform/ChartPlotAreaOASISTContext.cxx
+++ b/xmloff/source/transform/ChartPlotAreaOASISTContext.cxx
@@ -95,7 +95,7 @@ void XMLAxisOASISContext::StartElement(
     const Reference< xml::sax::XAttributeList >& rAttrList )
 {
     Reference< xml::sax::XAttributeList > xAttrList( rAttrList );
-    XMLMutableAttributeList *pMutableAttrList = nullptr;
+    rtl::Reference<XMLMutableAttributeList> pMutableAttrList;
     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     for( sal_Int16 i=0; i < nAttrCount; i++ )
     {
@@ -157,7 +157,7 @@ void XMLAxisOASISContext::EndElement()
         m_rCategoriesContext.is() )
     {
         OSL_ENSURE( GetAttrList().is(), "Invalid attribute list" );
-        XMLMutableAttributeList * pMutableAttrList =
+        rtl::Reference<XMLMutableAttributeList> pMutableAttrList =
             new XMLMutableAttributeList( GetAttrList());
         OUString aAttrQName( GetTransformer().GetNamespaceMap().GetQNameByKey(
                                  XML_NAMESPACE_CHART, GetXMLToken( XML_CLASS )));
diff --git a/xmloff/source/transform/ChartPlotAreaOOoTContext.cxx b/xmloff/source/transform/ChartPlotAreaOOoTContext.cxx
index a16945f3f612..f2781a25aa62 100644
--- a/xmloff/source/transform/ChartPlotAreaOOoTContext.cxx
+++ b/xmloff/source/transform/ChartPlotAreaOOoTContext.cxx
@@ -57,7 +57,7 @@ void XMLAxisOOoContext::StartElement(
     const Reference< xml::sax::XAttributeList >& rAttrList )
 {
     Reference< xml::sax::XAttributeList > xAttrList( rAttrList );
-    XMLMutableAttributeList *pMutableAttrList = nullptr;
+    rtl::Reference<XMLMutableAttributeList> pMutableAttrList;
     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     for( sal_Int16 i=0; i < nAttrCount; i++ )
     {
diff --git a/xmloff/source/transform/ControlOASISTContext.cxx b/xmloff/source/transform/ControlOASISTContext.cxx
index 552553e54533..5dd2067c7af7 100644
--- a/xmloff/source/transform/ControlOASISTContext.cxx
+++ b/xmloff/source/transform/ControlOASISTContext.cxx
@@ -51,7 +51,7 @@ void XMLControlOASISTransformerContext::StartElement(
     OSL_ENSURE( pActions, "go no actions" );
 
     Reference< XAttributeList > xAttrList( rAttrList );
-    XMLMutableAttributeList *pMutableAttrList = nullptr;
+    rtl::Reference<XMLMutableAttributeList> pMutableAttrList;
 //      GetTransformer().ProcessAttrList( xAttrList, OOO_SHAPE_ACTIONS,
 //                                        sal_True );
 
diff --git a/xmloff/source/transform/CreateElemTContext.cxx b/xmloff/source/transform/CreateElemTContext.cxx
index c22b86ef2b4c..218852972799 100644
--- a/xmloff/source/transform/CreateElemTContext.cxx
+++ b/xmloff/source/transform/CreateElemTContext.cxx
@@ -50,7 +50,7 @@ void XMLCreateElemTransformerContext::StartElement(
 
     std::vector<rtl::Reference<XMLTransformerContext>> aChildContexts;
 
-    XMLMutableAttributeList *pMutableAttrList = nullptr;
+    rtl::Reference<XMLMutableAttributeList> pMutableAttrList;
     XMLTransformerActions *pActions =
         GetTransformer().GetUserDefinedActions( m_nActionMap );
     OSL_ENSURE( pActions, "go no actions" );
diff --git a/xmloff/source/transform/DlgOASISTContext.cxx b/xmloff/source/transform/DlgOASISTContext.cxx
index 03578dc4584e..24b8a868ed49 100644
--- a/xmloff/source/transform/DlgOASISTContext.cxx
+++ b/xmloff/source/transform/DlgOASISTContext.cxx
@@ -48,7 +48,7 @@ void XMLDlgOASISTransformerContext::StartElement(
     OSL_ENSURE( pActions, "go no actions" );
 
     Reference< XAttributeList > xAttrList( rAttrList );
-    XMLMutableAttributeList *pMutableAttrList = nullptr;
+    rtl::Reference<XMLMutableAttributeList> pMutableAttrList;
     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
 
     for( sal_Int16 i=0; i < nAttrCount; i++ )
diff --git a/xmloff/source/transform/DocumentTContext.cxx b/xmloff/source/transform/DocumentTContext.cxx
index f75a00c94ed8..894146897af7 100644
--- a/xmloff/source/transform/DocumentTContext.cxx
+++ b/xmloff/source/transform/DocumentTContext.cxx
@@ -51,7 +51,7 @@ void XMLDocumentTransformerContext::StartElement( const Reference< XAttributeLis
                     GetTransformer().GetNamespaceMap().GetQNameByKey(
                                 XML_NAMESPACE_OFFICE, GetXMLToken(XML_CLASS ) ) );
 
-    XMLMutableAttributeList *pMutableAttrList = nullptr;
+    rtl::Reference<XMLMutableAttributeList> pMutableAttrList;
     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     for( sal_Int16 i=0; i < nAttrCount; i++ )
     {
diff --git a/xmloff/source/transform/EventOASISTContext.cxx b/xmloff/source/transform/EventOASISTContext.cxx
index be021572e521..21e3476ef8da 100644
--- a/xmloff/source/transform/EventOASISTContext.cxx
+++ b/xmloff/source/transform/EventOASISTContext.cxx
@@ -173,7 +173,7 @@ void XMLEventOASISTransformerContext::StartElement(
     SAL_WARN_IF( pActions == nullptr, "xmloff.transform", "got no actions" );
 
     Reference< XAttributeList > xAttrList( rAttrList );
-    XMLMutableAttributeList *pMutableAttrList = nullptr;
+    rtl::Reference<XMLMutableAttributeList> pMutableAttrList;
     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     for( sal_Int16 i=0; i < nAttrCount; i++ )
     {
diff --git a/xmloff/source/transform/EventOOoTContext.cxx b/xmloff/source/transform/EventOOoTContext.cxx
index 71566a3466e0..1611e6b7a10f 100644
--- a/xmloff/source/transform/EventOOoTContext.cxx
+++ b/xmloff/source/transform/EventOOoTContext.cxx
@@ -134,7 +134,7 @@ void XMLEventOOoTransformerContext::StartElement(
     OUString aLocation, aMacroName;
     sal_Int16 nMacroName = -1;
     Reference< XAttributeList > xAttrList( rAttrList );
-    XMLMutableAttributeList *pMutableAttrList = nullptr;
+    rtl::Reference<XMLMutableAttributeList> pMutableAttrList;
     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     for( sal_Int16 i=0; i < nAttrCount; i++ )
     {
diff --git a/xmloff/source/transform/FormPropOASISTContext.cxx b/xmloff/source/transform/FormPropOASISTContext.cxx
index 09ab09a0e37a..6b29f0da9816 100644
--- a/xmloff/source/transform/FormPropOASISTContext.cxx
+++ b/xmloff/source/transform/FormPropOASISTContext.cxx
@@ -104,7 +104,7 @@ void XMLFormPropOASISTransformerContext::StartElement(
         GetTransformer().GetUserDefinedActions( OASIS_FORM_PROP_ACTIONS );
     OSL_ENSURE( pActions, "go no actions" );
 
-    XMLMutableAttributeList *pMutableAttrList =
+    rtl::Reference<XMLMutableAttributeList> pMutableAttrList =
         new XMLMutableAttributeList( rAttrList );
     Reference< XAttributeList > xAttrList( pMutableAttrList );
 
diff --git a/xmloff/source/transform/FormPropOOoTContext.cxx b/xmloff/source/transform/FormPropOOoTContext.cxx
index 13d289ca89b8..1f5c6086dbfa 100644
--- a/xmloff/source/transform/FormPropOOoTContext.cxx
+++ b/xmloff/source/transform/FormPropOOoTContext.cxx
@@ -149,7 +149,7 @@ void XMLFormPropOOoTransformerContext::StartElement(
         GetTransformer().GetUserDefinedActions( OOO_FORM_PROP_ACTIONS );
     OSL_ENSURE( pActions, "go no actions" );
 
-    XMLMutableAttributeList *pMutableAttrList =
+    rtl::Reference<XMLMutableAttributeList> pMutableAttrList =
         new XMLMutableAttributeList( rAttrList, true );
     m_xAttrList = pMutableAttrList;
 
diff --git a/xmloff/source/transform/FrameOOoTContext.cxx b/xmloff/source/transform/FrameOOoTContext.cxx
index cb60b528384e..a8cbd5a8fbfa 100644
--- a/xmloff/source/transform/FrameOOoTContext.cxx
+++ b/xmloff/source/transform/FrameOOoTContext.cxx
@@ -50,14 +50,14 @@ void XMLFrameOOoTransformerContext::StartElement(
     OSL_ENSURE( pActions, "go no actions" );
 
     Reference< XAttributeList > xAttrList( rAttrList );
-    XMLMutableAttributeList *pMutableAttrList =
+    rtl::Reference<XMLMutableAttributeList> pMutableAttrList =
         GetTransformer().ProcessAttrList( xAttrList, OOO_SHAPE_ACTIONS,
                                           true );
     if( !pMutableAttrList )
         pMutableAttrList = new XMLMutableAttributeList( rAttrList );
     xAttrList = pMutableAttrList;
 
-    XMLMutableAttributeList *pFrameMutableAttrList =
+    rtl::Reference<XMLMutableAttributeList> pFrameMutableAttrList =
         new XMLMutableAttributeList;
     Reference< XAttributeList > xFrameAttrList( pFrameMutableAttrList );
 
diff --git a/xmloff/source/transform/MergeElemTContext.cxx b/xmloff/source/transform/MergeElemTContext.cxx
index 4beb2e016fe1..e853240f9e24 100644
--- a/xmloff/source/transform/MergeElemTContext.cxx
+++ b/xmloff/source/transform/MergeElemTContext.cxx
@@ -125,7 +125,7 @@ XMLMergeElemTransformerContext::XMLMergeElemTransformerContext(
 void XMLMergeElemTransformerContext::StartElement(
     const Reference< XAttributeList >& rAttrList )
 {
-    XMLMutableAttributeList *pMutableAttrList =
+    rtl::Reference<XMLMutableAttributeList> pMutableAttrList =
         new XMLMutableAttributeList( rAttrList, true );
     m_xAttrList = pMutableAttrList;
 
diff --git a/xmloff/source/transform/MutableAttrList.cxx b/xmloff/source/transform/MutableAttrList.cxx
index 622abc3fa168..abf19c69a2bc 100644
--- a/xmloff/source/transform/MutableAttrList.cxx
+++ b/xmloff/source/transform/MutableAttrList.cxx
@@ -34,7 +34,7 @@ SvXMLAttributeList *XMLMutableAttributeList::GetMutableAttrList()
         m_xAttrList = m_pMutableAttrList;
     }
 
-    return m_pMutableAttrList;
+    return m_pMutableAttrList.get();
 }
 
 XMLMutableAttributeList::XMLMutableAttributeList() :
@@ -45,8 +45,7 @@ XMLMutableAttributeList::XMLMutableAttributeList() :
 
 XMLMutableAttributeList::XMLMutableAttributeList( const Reference<
         XAttributeList> & rAttrList, bool bClone ) :
-    m_xAttrList( rAttrList.is() ? rAttrList : new SvXMLAttributeList ),
-    m_pMutableAttrList( nullptr )
+    m_xAttrList( rAttrList.is() ? rAttrList : new SvXMLAttributeList )
 {
     if( bClone )
         GetMutableAttrList();
diff --git a/xmloff/source/transform/MutableAttrList.hxx b/xmloff/source/transform/MutableAttrList.hxx
index ed8950042bee..c47720b2d2dd 100644
--- a/xmloff/source/transform/MutableAttrList.hxx
+++ b/xmloff/source/transform/MutableAttrList.hxx
@@ -25,6 +25,7 @@
 #include <com/sun/star/lang/XUnoTunnel.hpp>
 
 #include <cppuhelper/implbase.hxx>
+#include <rtl/ref.hxx>
 
 class SvXMLAttributeList;
 
@@ -35,7 +36,7 @@ class XMLMutableAttributeList : public ::cppu::WeakImplHelper<
 {
     css::uno::Reference< css::xml::sax::XAttributeList> m_xAttrList;
 
-    SvXMLAttributeList *m_pMutableAttrList;
+    rtl::Reference<SvXMLAttributeList> m_pMutableAttrList;
 
     SvXMLAttributeList *GetMutableAttrList();
 
diff --git a/xmloff/source/transform/NotesTContext.cxx b/xmloff/source/transform/NotesTContext.cxx
index 8c18cdb16531..9cd3b2e574b6 100644
--- a/xmloff/source/transform/NotesTContext.cxx
+++ b/xmloff/source/transform/NotesTContext.cxx
@@ -62,7 +62,7 @@ void XMLNotesTransformerContext::StartElement(
     OSL_ENSURE( pActions, "go no actions" );
 
     Reference< XAttributeList > xAttrList( rAttrList );
-    XMLMutableAttributeList *pMutableAttrList = nullptr;
+    rtl::Reference<XMLMutableAttributeList> pMutableAttrList;
     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     for( sal_Int16 i=0; i < nAttrCount; i++ )
     {
diff --git a/xmloff/source/transform/OOo2Oasis.cxx b/xmloff/source/transform/OOo2Oasis.cxx
index 4e860b64f620..c2c5cdf0a16c 100644
--- a/xmloff/source/transform/OOo2Oasis.cxx
+++ b/xmloff/source/transform/OOo2Oasis.cxx
@@ -1136,7 +1136,7 @@ void XMLDocumentTransformerContext_Impl::StartElement(
 
     m_aOldClass = GetTransformer().GetClass();
 
-    XMLMutableAttributeList *pMutableAttrList = nullptr;
+    rtl::Reference<XMLMutableAttributeList> pMutableAttrList;
     bool bOOo = false, bOOoW = false, bOOoC = false,
         bDOM=false, bDC = false, bSVG = false;
     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
@@ -1261,7 +1261,7 @@ void XMLBodyTransformerContext_Impl::StartElement(
 {
     XMLTransformerContext::StartElement( rAttrList );
 
-    XMLMutableAttributeList *pMutableAttrList =
+    rtl::Reference<XMLMutableAttributeList> pMutableAttrList =
         new XMLMutableAttributeList( rAttrList );
     Reference< XAttributeList > xAttrList = pMutableAttrList;
     OUString aClass( GetTransformer().GetClass() );
@@ -1319,7 +1319,7 @@ void XMLTabStopOOoTContext_Impl::StartElement(
     OSL_ENSURE( pActions, "go no actions" );
 
     Reference< XAttributeList > xAttrList( rAttrList );
-    XMLMutableAttributeList *pMutableAttrList = nullptr;
+    rtl::Reference<XMLMutableAttributeList> pMutableAttrList;
     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     for( sal_Int16 i=0; i < nAttrCount; i++ )
     {
diff --git a/xmloff/source/transform/Oasis2OOo.cxx b/xmloff/source/transform/Oasis2OOo.cxx
index 3e888d1ad7e2..0fda0c3b61c2 100644
--- a/xmloff/source/transform/Oasis2OOo.cxx
+++ b/xmloff/source/transform/Oasis2OOo.cxx
@@ -1177,7 +1177,7 @@ void XMLTableTransformerContext_Impl::StartElement(
 {
     Reference< XAttributeList > xAttrList( rAttrList );
 
-    XMLMutableAttributeList *pMutableAttrList = nullptr;
+    rtl::Reference<XMLMutableAttributeList> pMutableAttrList;
 
     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     for( sal_Int16 i=0; i < nAttrCount; i++ )
@@ -1330,7 +1330,7 @@ void XMLTabStopOASISTContext_Impl::StartElement(
     sal_Unicode cStyleLeaderChar = 0;
     sal_Int16 nLeaderText = -1;
     Reference< XAttributeList > xAttrList( rAttrList );
-    XMLMutableAttributeList *pMutableAttrList = nullptr;
+    rtl::Reference<XMLMutableAttributeList> pMutableAttrList;
     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     for( sal_Int16 i=0; i < nAttrCount; i++ )
     {
@@ -1578,7 +1578,7 @@ void XMLTrackedChangesOASISTContext_Impl::StartElement(
             {
                 OUStringBuffer aBuffer;
                 ::comphelper::Base64::encode( aBuffer, aKey );
-                XMLMutableAttributeList *pMutableAttrList =
+                rtl::Reference<XMLMutableAttributeList> pMutableAttrList =
                     new XMLMutableAttributeList( xAttrList );
                 xAttrList = pMutableAttrList;
                 pMutableAttrList->AddAttribute( m_aAttrQName,
diff --git a/xmloff/source/transform/PersAttrListTContext.cxx b/xmloff/source/transform/PersAttrListTContext.cxx
index abb01f9ab6d4..53e20b0a36bf 100644
--- a/xmloff/source/transform/PersAttrListTContext.cxx
+++ b/xmloff/source/transform/PersAttrListTContext.cxx
@@ -47,7 +47,7 @@ void XMLPersAttrListTContext::AddAttribute(
                 nAPrefix, ::xmloff::token::GetXMLToken( eAToken ) ) );
     const OUString& aAttrValue( rValue );
 
-    XMLMutableAttributeList *pMutableAttrList;
+    rtl::Reference<XMLMutableAttributeList> pMutableAttrList;
     if( m_xAttrList.is() )
     {
         pMutableAttrList =
diff --git a/xmloff/source/transform/ProcAddAttrTContext.cxx b/xmloff/source/transform/ProcAddAttrTContext.cxx
index bc9391acbb50..d15002ad209a 100644
--- a/xmloff/source/transform/ProcAddAttrTContext.cxx
+++ b/xmloff/source/transform/ProcAddAttrTContext.cxx
@@ -51,7 +51,7 @@ void XMLProcAddAttrTransformerContext::StartElement(
         const Reference< XAttributeList >& rAttrList )
 {
     Reference< XAttributeList > xAttrList( rAttrList );
-    XMLMutableAttributeList *pMutableAttrList =
+    rtl::Reference<XMLMutableAttributeList> pMutableAttrList =
         GetTransformer().ProcessAttrList( xAttrList, GetActionMap(),
                                           false );
     if( !pMutableAttrList )
diff --git a/xmloff/source/transform/RenameElemTContext.cxx b/xmloff/source/transform/RenameElemTContext.cxx
index 8ed242f248eb..5800d9346311 100644
--- a/xmloff/source/transform/RenameElemTContext.cxx
+++ b/xmloff/source/transform/RenameElemTContext.cxx
@@ -64,7 +64,7 @@ void XMLRenameElemTransformerContext::StartElement(
     Reference< XAttributeList > xAttrList( rAttrList );
     if( !m_aAttrQName.isEmpty() )
     {
-        XMLMutableAttributeList *pMutableAttrList =
+        rtl::Reference<XMLMutableAttributeList> pMutableAttrList =
             new XMLMutableAttributeList( xAttrList );
         xAttrList = pMutableAttrList;
         pMutableAttrList->AddAttribute( m_aAttrQName, m_aAttrValue );
diff --git a/xmloff/source/transform/StyleOASISTContext.cxx b/xmloff/source/transform/StyleOASISTContext.cxx
index b1d64260ac21..75dd62db6374 100644
--- a/xmloff/source/transform/StyleOASISTContext.cxx
+++ b/xmloff/source/transform/StyleOASISTContext.cxx
@@ -115,7 +115,7 @@ void XMLPropertiesTContext_Impl::StartElement(
 
     if( pActions )
     {
-        XMLMutableAttributeList *pAttrList = nullptr;
+        rtl::Reference<XMLMutableAttributeList> pAttrList;
         if( !m_xAttrList.is() )
         {
             pAttrList = new XMLMutableAttributeList();
@@ -786,7 +786,7 @@ void XMLStyleOASISTContext::StartElement(
     OSL_ENSURE( pActions, "go no actions" );
 
     Reference< XAttributeList > xAttrList( rAttrList );
-    XMLMutableAttributeList *pMutableAttrList = nullptr;
+    rtl::Reference<XMLMutableAttributeList> pMutableAttrList;
     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     sal_Int16 nFamilyAttr = -1;
     m_bControlStyle = false;
diff --git a/xmloff/source/transform/StyleOOoTContext.cxx b/xmloff/source/transform/StyleOOoTContext.cxx
index fd6d082822cd..c9c9220adc44 100644
--- a/xmloff/source/transform/StyleOOoTContext.cxx
+++ b/xmloff/source/transform/StyleOOoTContext.cxx
@@ -1121,7 +1121,7 @@ void XMLStyleOOoTContext::StartElement(
     OSL_ENSURE( pActions, "go no actions" );
 
     Reference< XAttributeList > xAttrList( rAttrList );
-    XMLMutableAttributeList *pMutableAttrList = nullptr;
+    rtl::Reference<XMLMutableAttributeList> pMutableAttrList;
     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     for( sal_Int16 i=0; i < nAttrCount; i++ )
     {
diff --git a/xmloff/source/transform/TransformerBase.cxx b/xmloff/source/transform/TransformerBase.cxx
index fd59d2c8bb96..15a5859f95ef 100644
--- a/xmloff/source/transform/TransformerBase.cxx
+++ b/xmloff/source/transform/TransformerBase.cxx
@@ -210,7 +210,7 @@ void SAL_CALL XMLTransformerBase::startElement( const OUString& rName,
 
     // Process namespace attributes. This must happen before creating the
     // context, because namespace declaration apply to the element name itself.
-    XMLMutableAttributeList *pMutableAttrList = nullptr;
+    rtl::Reference<XMLMutableAttributeList> pMutableAttrList;
     Reference< XAttributeList > xAttrList( rAttrList );
     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     for( sal_Int16 i=0; i < nAttrCount; i++ )
@@ -469,7 +469,7 @@ XMLMutableAttributeList *XMLTransformerBase::ProcessAttrList(
         Reference< XAttributeList >& rAttrList, sal_uInt16 nActionMap,
            bool bClone  )
 {
-    XMLMutableAttributeList *pMutableAttrList = nullptr;
+    rtl::Reference<XMLMutableAttributeList> pMutableAttrList;
     XMLTransformerActions *pActions = GetUserDefinedActions( nActionMap );
     OSL_ENSURE( pActions, "go no actions" );
     if( pActions )
@@ -859,7 +859,7 @@ XMLMutableAttributeList *XMLTransformerBase::ProcessAttrList(
         }
     }
 
-    return pMutableAttrList;
+    return pMutableAttrList.get();
 }
 
 bool XMLTransformerBase::ReplaceSingleInchWithIn( OUString& rValue )
commit 1e8e8327847c18e6dac09615d7d905298f608e8c
Author:     Noel <noel.grandin at collabora.co.uk>
AuthorDate: Thu Feb 18 15:06:04 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Feb 19 07:35:20 2021 +0100

    loplugin:refcounting in xmlsecurity
    
    Change-Id: Ic5227df4bd5b1f3dfe9cd13ae971d268a40f0fcf
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111120
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/xmlsecurity/source/gpg/SecurityEnvironment.cxx b/xmlsecurity/source/gpg/SecurityEnvironment.cxx
index 290529bc8ae6..98db7e420a38 100644
--- a/xmlsecurity/source/gpg/SecurityEnvironment.cxx
+++ b/xmlsecurity/source/gpg/SecurityEnvironment.cxx
@@ -15,6 +15,7 @@
 
 #include <comphelper/servicehelper.hxx>
 #include <vector>
+#include <rtl/ref.hxx>
 
 #ifdef _WIN32
 #include <config_folders.h>
@@ -116,9 +117,8 @@ OUString SecurityEnvironmentGpg::getSecurityEnvironmentInformation()
 
 Sequence< Reference < XCertificate > > SecurityEnvironmentGpg::getCertificatesImpl( bool bPrivateOnly )
 {
-    CertificateImpl* xCert;
     std::vector< GpgME::Key > keyList;
-    std::vector< CertificateImpl* > certsList;
+    std::vector< rtl::Reference<CertificateImpl> > certsList;
 
     m_ctx->setKeyListMode(GPGME_KEYLIST_MODE_LOCAL);
     GpgME::Error err = m_ctx->startKeyListing("", bPrivateOnly );
@@ -135,14 +135,14 @@ Sequence< Reference < XCertificate > > SecurityEnvironmentGpg::getCertificatesIm
     m_ctx->endKeyListing();
 
     for (auto const& key : keyList) {
-        xCert = new CertificateImpl();
+        rtl::Reference<CertificateImpl> xCert = new CertificateImpl();
         xCert->setCertificate(m_ctx.get(),key);
         certsList.push_back(xCert);
     }
 
     Sequence< Reference< XCertificate > > xCertificateSequence(certsList.size());
     int i = 0;
-    for (auto const& cert : certsList) {
+    for (auto& cert : certsList) {
         xCertificateSequence[i++] = cert;
     }
 
@@ -161,8 +161,6 @@ Sequence< Reference < XCertificate > > SecurityEnvironmentGpg::getAllCertificate
 
 Reference< XCertificate > SecurityEnvironmentGpg::getCertificate( const OUString& keyId, const Sequence< sal_Int8 >& /*serialNumber*/ )
 {
-    CertificateImpl* xCert=nullptr;
-
     //xmlChar* pSignatureValue=xmlNodeGetContent(cur);
     OString ostr = OUStringToOString( keyId , RTL_TEXTENCODING_UTF8 );
     const xmlChar* strKeyId = reinterpret_cast<const xmlChar*>(ostr.getStr());
@@ -176,7 +174,7 @@ Reference< XCertificate > SecurityEnvironmentGpg::getCertificate( const OUString
         if (err)
             break;
         if (!k.isInvalid() && strcmp(k.primaryFingerprint(), reinterpret_cast<const char*>(strKeyId)) == 0) {
-            xCert = new CertificateImpl();
+            rtl::Reference<CertificateImpl> xCert = new CertificateImpl();
             xCert->setCertificate(m_ctx.get(), k);
             m_ctx->endKeyListing();
             return xCert;
diff --git a/xmlsecurity/source/helper/xmlsignaturehelper.cxx b/xmlsecurity/source/helper/xmlsignaturehelper.cxx
index 9977da48f72c..779f95119198 100644
--- a/xmlsecurity/source/helper/xmlsignaturehelper.cxx
+++ b/xmlsecurity/source/helper/xmlsignaturehelper.cxx
@@ -184,7 +184,7 @@ uno::Reference<xml::sax::XWriter> XMLSignatureHelper::CreateDocumentHandlerWithH
     /*
      * write the xml context for signatures
      */
-    SvXMLAttributeList *pAttributeList = new SvXMLAttributeList();
+    rtl::Reference<SvXMLAttributeList> pAttributeList = new SvXMLAttributeList();
     OUString sNamespace;
     if (mbODFPre1_2)
         sNamespace = NS_DOCUMENTSIGNATURES;
@@ -198,7 +198,7 @@ uno::Reference<xml::sax::XWriter> XMLSignatureHelper::CreateDocumentHandlerWithH
     xSaxWriter->startDocument();
     xSaxWriter->startElement(
         "document-signatures",
-        uno::Reference< css::xml::sax::XAttributeList > (pAttributeList));
+        pAttributeList);
 
     return xSaxWriter;
 }
diff --git a/xmlsecurity/source/helper/xsecctl.cxx b/xmlsecurity/source/helper/xsecctl.cxx
index 1607539bb9d5..697d84a8e2a0 100644
--- a/xmlsecurity/source/helper/xsecctl.cxx
+++ b/xmlsecurity/source/helper/xsecctl.cxx
@@ -580,7 +580,7 @@ void XSecController::exportSignature(
  ******************************************************************************/
 {
     const SignatureReferenceInformations& vReferenceInfors = signatureInfo.vSignatureReferenceInfors;
-    SvXMLAttributeList *pAttributeList;
+    rtl::Reference<SvXMLAttributeList> pAttributeList;
 
     /*
      * Write Signature element
@@ -597,7 +597,7 @@ void XSecController::exportSignature(
             signatureInfo.ouSignatureId);
     }
 
-    xDocumentHandler->startElement( "Signature", css::uno::Reference< css::xml::sax::XAttributeList > (pAttributeList));
+    xDocumentHandler->startElement( "Signature", pAttributeList);
     {
         /* Write SignedInfo element */
         xDocumentHandler->startElement(
@@ -609,7 +609,7 @@ void XSecController::exportSignature(
             pAttributeList->AddAttribute(
                 "Algorithm",
                 ALGO_C14N);
-            xDocumentHandler->startElement( "CanonicalizationMethod", css::uno::Reference< css::xml::sax::XAttributeList > (pAttributeList) );
+            xDocumentHandler->startElement( "CanonicalizationMethod", pAttributeList );
             xDocumentHandler->endElement( "CanonicalizationMethod" );
 
             /* Write SignatureMethod element */
@@ -623,7 +623,7 @@ void XSecController::exportSignature(
             pAttributeList->AddAttribute(
                 "Algorithm",
                 getSignatureURI(signatureInfo.eAlgorithmID, vReferenceInfors[0].nDigestID));
-            xDocumentHandler->startElement( "SignatureMethod", css::uno::Reference< css::xml::sax::XAttributeList > (pAttributeList) );
+            xDocumentHandler->startElement( "SignatureMethod", pAttributeList );
             xDocumentHandler->endElement( "SignatureMethod" );
 
             /* Write Reference element */
@@ -662,7 +662,7 @@ void XSecController::exportSignature(
                     }
                 }
 
-                xDocumentHandler->startElement( "Reference", css::uno::Reference< css::xml::sax::XAttributeList > (pAttributeList) );
+                xDocumentHandler->startElement( "Reference", pAttributeList );
                 {
                     /* Write Transforms element */
                     if (refInfor.nType == SignatureReferenceType::XMLSTREAM)
@@ -680,7 +680,7 @@ void XSecController::exportSignature(
                                 ALGO_C14N);
                             xDocumentHandler->startElement(
                                 "Transform",
-                                css::uno::Reference< css::xml::sax::XAttributeList > (pAttributeList) );
+                                pAttributeList );
                             xDocumentHandler->endElement( "Transform" );
                         }
                         xDocumentHandler->endElement( "Transforms" );
@@ -693,7 +693,7 @@ void XSecController::exportSignature(
                         getDigestURI(refInfor.nDigestID));
                     xDocumentHandler->startElement(
                         "DigestMethod",
-                        css::uno::Reference< css::xml::sax::XAttributeList > (pAttributeList) );
+                        pAttributeList );
                     xDocumentHandler->endElement( "DigestMethod" );
 
                     /* Write DigestValue element */
@@ -728,7 +728,7 @@ void XSecController::exportSignature(
                 /* Write PGPData element */
                 xDocumentHandler->startElement(
                     "PGPData",
-                    css::uno::Reference< css::xml::sax::XAttributeList > (pAttributeList));
+                    pAttributeList);
                 {
                     /* Write keyid element */
                     xDocumentHandler->startElement(
@@ -821,7 +821,7 @@ void XSecController::exportSignature(
                     "#" + signatureInfo.ouSignatureId);
                 xDocumentHandler->startElement(
                     "SignatureProperty",
-                    css::uno::Reference< css::xml::sax::XAttributeList > (pAttributeList));
+                    pAttributeList);
                 {
                     /* Write timestamp element */
 
@@ -832,7 +832,7 @@ void XSecController::exportSignature(
 
                     xDocumentHandler->startElement(
                         "dc:date",
-                        css::uno::Reference< css::xml::sax::XAttributeList > (pAttributeList));
+                        pAttributeList);
 
                     OUStringBuffer buffer;
                     //If the xml signature was already contained in the document,
@@ -864,14 +864,14 @@ void XSecController::exportSignature(
                 pAttributeList = new SvXMLAttributeList();
                 pAttributeList->AddAttribute("Id", signatureInfo.ouDescriptionPropertyId);
                 pAttributeList->AddAttribute("Target", "#" + signatureInfo.ouSignatureId);
-                xDocumentHandler->startElement("SignatureProperty", uno::Reference<xml::sax::XAttributeList>(pAttributeList));
+                xDocumentHandler->startElement("SignatureProperty", pAttributeList);
 
                 {
                     // Description element.
                     pAttributeList = new SvXMLAttributeList();
                     pAttributeList->AddAttribute("xmlns:dc", NS_DC);
 
-                    xDocumentHandler->startElement("dc:description", uno::Reference<xml::sax::XAttributeList>(pAttributeList));
+                    xDocumentHandler->startElement("dc:description", pAttributeList);
                     xDocumentHandler->characters(signatureInfo.ouDescription);
                     xDocumentHandler->endElement("dc:description");
                 }
@@ -890,13 +890,13 @@ void XSecController::exportSignature(
             pAttributeList->AddAttribute("xmlns:xd", NS_XD);
             xDocumentHandler->startElement(
                 "Object",
-                css::uno::Reference< css::xml::sax::XAttributeList > (pAttributeList));
+                pAttributeList);
             {
                 pAttributeList = new SvXMLAttributeList();
                 pAttributeList->AddAttribute("Target", "#" + signatureInfo.ouSignatureId);
                 xDocumentHandler->startElement(
                     "xd:QualifyingProperties",
-                    css::uno::Reference< css::xml::sax::XAttributeList > (pAttributeList));
+                    pAttributeList);
                 DocumentSignatureHelper::writeSignedProperties(xDocumentHandler, signatureInfo, sDate, true);
                 writeUnsignedProperties(xDocumentHandler, signatureInfo);
                 xDocumentHandler->endElement( "xd:QualifyingProperties" );
diff --git a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx
index 1d2a7c2ec08f..f982e136f5b2 100644
--- a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx
+++ b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx
@@ -68,8 +68,8 @@ template <> struct default_delete<PRArenaPool>
 };
 }
 
-static X509Certificate_NssImpl* NssCertToXCert( CERTCertificate* cert ) ;
-static X509Certificate_NssImpl* NssPrivKeyToXCert( SECKEYPrivateKey* ) ;
+static rtl::Reference<X509Certificate_NssImpl> NssCertToXCert( CERTCertificate* cert ) ;
+static rtl::Reference<X509Certificate_NssImpl> NssPrivKeyToXCert( SECKEYPrivateKey* ) ;
 
 namespace {
 
@@ -98,11 +98,10 @@ static char* GetPasswordFunction( PK11SlotInfo* pSlot, PRBool bRetry, void* /*ar
         task::InteractionHandler::createWithParent(xContext, nullptr) );
 
     task::PasswordRequestMode eMode = bRetry ? task::PasswordRequestMode_PASSWORD_REENTER : task::PasswordRequestMode_PASSWORD_ENTER;
-    ::comphelper::DocPasswordRequest* pPasswordRequest = new ::comphelper::DocPasswordRequest(
+    rtl::Reference<::comphelper::DocPasswordRequest> pPasswordRequest = new ::comphelper::DocPasswordRequest(
         ::comphelper::DocPasswordRequestType::Standard, eMode, OUString::createFromAscii(PK11_GetTokenName(pSlot)) );
 
-    uno::Reference< task::XInteractionRequest > xRequest( pPasswordRequest );
-    xInteractionHandler->handle( xRequest );
+    xInteractionHandler->handle( pPasswordRequest );
 
     if ( pPasswordRequest->isPassword() )
     {
@@ -272,8 +271,7 @@ Sequence< Reference < XCertificate > >
 SecurityEnvironment_NssImpl::getPersonalCertificates()
 {
     sal_Int32 length ;
-    X509Certificate_NssImpl* xcert ;
-    std::vector< X509Certificate_NssImpl* > certsList ;
+    std::vector< rtl::Reference<X509Certificate_NssImpl> > certsList ;
 
     updateSlots();
     //firstly, we try to find private keys in slot
@@ -298,7 +296,7 @@ SecurityEnvironment_NssImpl::getPersonalCertificates()
                 !PRIVKEY_LIST_END( curPri, priKeyList ) && curPri != nullptr;
                 curPri = PRIVKEY_LIST_NEXT(curPri))
             {
-                xcert = NssPrivKeyToXCert( curPri->key ) ;
+                rtl::Reference<X509Certificate_NssImpl> xcert = NssPrivKeyToXCert( curPri->key ) ;
                 if( xcert != nullptr )
                     certsList.push_back( xcert ) ;
             }
@@ -313,7 +311,7 @@ SecurityEnvironment_NssImpl::getPersonalCertificates()
         int i = 0;
         Sequence< Reference< XCertificate > > certSeq( length ) ;
 
-        for( const auto& rXCert : certsList ) {
+        for( auto& rXCert : certsList ) {
             certSeq[i] = rXCert ;
             ++i;
         }
@@ -326,7 +324,7 @@ SecurityEnvironment_NssImpl::getPersonalCertificates()
 
 Reference< XCertificate > SecurityEnvironment_NssImpl::getCertificate( const OUString& issuerName, const Sequence< sal_Int8 >& serialNumber )
 {
-    X509Certificate_NssImpl* xcert = nullptr;
+    rtl::Reference<X509Certificate_NssImpl> xcert;
 
     if( m_pHandler != nullptr ) {
         CERTIssuerAndSN issuerAndSN ;
@@ -365,16 +363,12 @@ Reference< XCertificate > SecurityEnvironment_NssImpl::getCertificate( const OUS
         cert = CERT_FindCertByIssuerAndSN( m_pHandler, &issuerAndSN ) ;
         if( cert != nullptr ) {
             xcert = NssCertToXCert( cert ) ;
-        } else {
-            xcert = nullptr ;
         }
 
         PL_strfree( chIssuer ) ;
         CERT_DestroyName( nmIssuer ) ;
         //SECITEM_FreeItem( derIssuer, PR_FALSE ) ;
         CERT_DestroyCertificate( cert ) ;
-    } else {
-        xcert = nullptr ;
     }
 
     return xcert ;
@@ -411,7 +405,7 @@ Sequence< Reference < XCertificate > > SecurityEnvironment_NssImpl::buildCertifi
         std::vector<uno::Reference<security::XCertificate>> aCertChain;
 
         for (CERTCertListNode* node = CERT_LIST_HEAD(certChain); !CERT_LIST_END(node, certChain); node = CERT_LIST_NEXT(node)) {
-            X509Certificate_NssImpl* pCert = new X509Certificate_NssImpl();
+            rtl::Reference<X509Certificate_NssImpl> pCert = new X509Certificate_NssImpl();
             if( pCert == nullptr ) {
                 CERT_DestroyCertList( certChain ) ;
                 throw RuntimeException() ;
@@ -430,7 +424,7 @@ Sequence< Reference < XCertificate > > SecurityEnvironment_NssImpl::buildCertifi
     return Sequence< Reference < XCertificate > >();
 }
 
-X509Certificate_NssImpl* SecurityEnvironment_NssImpl::createAndAddCertificateFromPackage(
+rtl::Reference<X509Certificate_NssImpl> SecurityEnvironment_NssImpl::createAndAddCertificateFromPackage(
                                                         const css::uno::Sequence<sal_Int8>& raDERCertificate,
                                                         std::u16string_view raString)
 {
@@ -479,14 +473,14 @@ X509Certificate_NssImpl* SecurityEnvironment_NssImpl::createAndAddCertificateFro
 
     PK11_FreeSlot(pSlot);
 
-    X509Certificate_NssImpl* pX509Certificate = new X509Certificate_NssImpl();
+    rtl::Reference<X509Certificate_NssImpl> pX509Certificate = new X509Certificate_NssImpl();
     pX509Certificate->setCert(pCERTCertificate);
     return pX509Certificate;
 }
 
-X509Certificate_NssImpl* SecurityEnvironment_NssImpl::createX509CertificateFromDER(const css::uno::Sequence<sal_Int8>& aDerCertificate)
+rtl::Reference<X509Certificate_NssImpl> SecurityEnvironment_NssImpl::createX509CertificateFromDER(const css::uno::Sequence<sal_Int8>& aDerCertificate)
 {
-    X509Certificate_NssImpl* pX509Certificate = nullptr;
+    rtl::Reference<X509Certificate_NssImpl> pX509Certificate;
 
     if (aDerCertificate.hasElements())
     {
@@ -803,39 +797,32 @@ sal_Int32 SecurityEnvironment_NssImpl::getCertificateCharacters(
     return characters ;
 }
 
-X509Certificate_NssImpl* NssCertToXCert( CERTCertificate* cert )
+rtl::Reference<X509Certificate_NssImpl> NssCertToXCert( CERTCertificate* cert )
 {
-    X509Certificate_NssImpl* xcert ;
-
     if( cert != nullptr ) {
-        xcert = new X509Certificate_NssImpl() ;
+        rtl::Reference<X509Certificate_NssImpl> xcert = new X509Certificate_NssImpl() ;
         xcert->setCert( cert ) ;
-    } else {
-        xcert = nullptr ;
+        return xcert;
     }
 
-    return xcert ;
+    return nullptr;
 }
 
-X509Certificate_NssImpl* NssPrivKeyToXCert( SECKEYPrivateKey* priKey )
+rtl::Reference<X509Certificate_NssImpl> NssPrivKeyToXCert( SECKEYPrivateKey* priKey )
 {
-    X509Certificate_NssImpl* xcert ;
-
     if( priKey != nullptr ) {
+        rtl::Reference<X509Certificate_NssImpl> xcert;
         CERTCertificate* cert = PK11_GetCertFromPrivateKey( priKey ) ;
 
         if( cert != nullptr ) {
             xcert = NssCertToXCert( cert ) ;
-        } else {
-            xcert = nullptr ;
         }
 
         CERT_DestroyCertificate( cert ) ;
-    } else {
-        xcert = nullptr ;
+        return xcert;
     }
 
-    return xcert ;
+    return nullptr;
 }
 
 xmlSecKeysMngrPtr SecurityEnvironment_NssImpl::createKeysManager() {
@@ -924,18 +911,13 @@ uno::Reference<security::XCertificate> SecurityEnvironment_NssImpl::createDERCer
     if (!pPrivateKey)
         return uno::Reference<security::XCertificate>();
 
-    X509Certificate_NssImpl* pX509Certificate = createAndAddCertificateFromPackage(raDERCertificate, u"TCu,TCu,TCu");
-    if (!pX509Certificate)
-        return uno::Reference<security::XCertificate>();
-
-    return pX509Certificate;
+    return createAndAddCertificateFromPackage(raDERCertificate, u"TCu,TCu,TCu");
 }
 
 uno::Reference<security::XCertificate> SecurityEnvironment_NssImpl::addDERCertificateToTheDatabase(
         uno::Sequence<sal_Int8> const & raDERCertificate, OUString const & raTrustString)
 {
-    X509Certificate_NssImpl* pX509Certificate = createAndAddCertificateFromPackage(raDERCertificate, raTrustString);
-    return pX509Certificate;
+    return createAndAddCertificateFromPackage(raDERCertificate, raTrustString);
 }
 
 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
diff --git a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.hxx b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.hxx
index fcc51072a690..d29e4a24f90b 100644
--- a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.hxx
+++ b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.hxx
@@ -22,6 +22,7 @@
 
 #include <sal/config.h>
 #include <rtl/ustring.hxx>
+#include <rtl/ref.hxx>
 #include <cppuhelper/implbase.hxx>
 
 #include <com/sun/star/uno/Reference.hxx>
@@ -131,12 +132,12 @@ private:
 
         void updateSlots();
 
-        static X509Certificate_NssImpl* createAndAddCertificateFromPackage(
+        static rtl::Reference<X509Certificate_NssImpl> createAndAddCertificateFromPackage(
                                     const css::uno::Sequence<sal_Int8>& raDerCertificate,
                                     std::u16string_view raString);
         static SECKEYPrivateKey* insertPrivateKey(css::uno::Sequence<sal_Int8> const & raPrivateKey);
 
-        static X509Certificate_NssImpl* createX509CertificateFromDER(const css::uno::Sequence<sal_Int8>& raDerCertificate);
+        static rtl::Reference<X509Certificate_NssImpl> createX509CertificateFromDER(const css::uno::Sequence<sal_Int8>& raDerCertificate);
 
           /// @throws css::uno::Exception
           /// @throws css::uno::RuntimeException
diff --git a/xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.cxx
index 1a323d33f32f..15ec8a346895 100644
--- a/xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.cxx
+++ b/xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.cxx
@@ -210,13 +210,13 @@ css::uno::Sequence< css::uno::Reference< css::security::XCertificateExtension >
 
             if (objID == "2.5.29.17")
             {
-                SanExtensionImpl* pExtn = new SanExtensionImpl;
+                rtl::Reference<SanExtensionImpl> pExtn = new SanExtensionImpl;
                 pExtn->setCertExtn(value, vlen, objid, objidlen, crit);
                 xExtns[len] = pExtn ;
             }
             else
             {
-                CertificateExtension_XmlSecImpl* pExtn = new CertificateExtension_XmlSecImpl;
+                rtl::Reference<CertificateExtension_XmlSecImpl> pExtn = new CertificateExtension_XmlSecImpl;
                 pExtn->setCertExtn(value, vlen, objid, objidlen, crit);
                 xExtns[len] = pExtn;
             }
diff --git a/xmlsecurity/source/xmlsec/xmldocumentwrapper_xmlsecimpl.cxx b/xmlsecurity/source/xmlsec/xmldocumentwrapper_xmlsecimpl.cxx
index a9e95866d89f..430bb996fe21 100644
--- a/xmlsecurity/source/xmlsec/xmldocumentwrapper_xmlsecimpl.cxx
+++ b/xmlsecurity/source/xmlsec/xmldocumentwrapper_xmlsecimpl.cxx
@@ -27,6 +27,7 @@
 #include "xmlelementwrapper_xmlsecimpl.hxx"
 
 #include <xmloff/attrlist.hxx>
+#include <rtl/ref.hxx>
 
 #ifdef UNX
 #define stricmp strcasecmp
@@ -173,8 +174,7 @@ void XMLDocumentWrapper_XmlSecImpl::sendStartElement(
  *          This node must be an element type.
  ******************************************************************************/
 {
-    SvXMLAttributeList* pAttributeList = new SvXMLAttributeList();
-    uno::Reference < css::xml::sax::XAttributeList > xAttrList(pAttributeList);
+    rtl::Reference<SvXMLAttributeList> pAttributeList = new SvXMLAttributeList();
 
     xmlNsPtr pNsDef = pNode->nsDef;
 
@@ -230,12 +230,12 @@ void XMLDocumentWrapper_XmlSecImpl::sendStartElement(
     {
         xHandler->startElement(
             OUString::fromUtf8(sNodeName),
-            xAttrList);
+            pAttributeList);
     }
 
     xHandler2->startElement(
         OUString::fromUtf8(sNodeName),
-        xAttrList);
+        pAttributeList);
 }
 
 void XMLDocumentWrapper_XmlSecImpl::sendEndElement(
@@ -578,8 +578,7 @@ void XMLDocumentWrapper_XmlSecImpl::rebuildIDLink(xmlNodePtr pNode) const
 /* XXMLDocumentWrapper */
 uno::Reference< css::xml::wrapper::XXMLElementWrapper > SAL_CALL XMLDocumentWrapper_XmlSecImpl::getCurrentElement(  )
 {
-    XMLElementWrapper_XmlSecImpl* pElement = new XMLElementWrapper_XmlSecImpl(m_pCurrentElement);
-    return uno::Reference< css::xml::wrapper::XXMLElementWrapper >(pElement);
+    return new XMLElementWrapper_XmlSecImpl(m_pCurrentElement);
 }
 
 void SAL_CALL XMLDocumentWrapper_XmlSecImpl::setCurrentElement( const uno::Reference< css::xml::wrapper::XXMLElementWrapper >& element )


More information about the Libreoffice-commits mailing list