[Libreoffice-commits] core.git: connectivity/source dbaccess/source include/connectivity

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Thu Sep 23 19:58:42 UTC 2021


 connectivity/source/commontools/TTableHelper.cxx |    8 ++++----
 connectivity/source/drivers/ado/ATable.cxx       |    6 +++---
 connectivity/source/drivers/component/CTable.cxx |    2 +-
 connectivity/source/drivers/dbase/DTable.cxx     |    9 ++++-----
 connectivity/source/drivers/evoab2/NTable.cxx    |    2 +-
 connectivity/source/drivers/file/FTable.cxx      |    2 +-
 connectivity/source/drivers/flat/ETable.cxx      |    2 +-
 connectivity/source/drivers/macab/MacabTable.cxx |    2 +-
 connectivity/source/inc/dbase/DColumns.hxx       |    1 -
 connectivity/source/sdbcx/VTable.cxx             |    4 ++--
 dbaccess/source/core/api/RowSet.hxx              |    1 +
 include/connectivity/sdbcx/VTable.hxx            |    7 ++++---
 12 files changed, 23 insertions(+), 23 deletions(-)

New commits:
commit ebe57117c470a87a6b4201537616bd1379257c02
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Sep 23 15:03:45 2021 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Sep 23 21:58:09 2021 +0200

    leaks of OCollection in dbase import
    
    presumably since...
    
    commit 5c7b954935369cbbd22a6f43be63ac7c0ddbbfdc
    Date:   Mon Jan 29 13:28:44 2018 +0200
    
        loplugin:useuniqueptr in OTable
    
    OCollection has a unique and nonstandard acquire/release which forwards
    to a parent cppu::OWeakObject. So when it would appear to a casual
    observer, who assumes that it has an internal refcount, that its
    refcount would drop to zero and then get auto-deleted, nothing of the
    kind occurs.
    
    Change-Id: Ic292663a61b4d7dbf7636be7ad4c00aed0b5a7fa
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122528
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/connectivity/source/commontools/TTableHelper.cxx b/connectivity/source/commontools/TTableHelper.cxx
index 9c955a7e0104..3235c69ae8ef 100644
--- a/connectivity/source/commontools/TTableHelper.cxx
+++ b/connectivity/source/commontools/TTableHelper.cxx
@@ -296,7 +296,7 @@ void OTableHelper::refreshColumns()
     if(m_xColumns)
         m_xColumns->reFill(aVector);
     else
-        m_xColumns = createColumns(aVector);
+        m_xColumns.reset(createColumns(aVector));
 }
 
 const ColumnDesc* OTableHelper::getColumnDescription(const OUString& _sName) const
@@ -413,10 +413,10 @@ void OTableHelper::refreshKeys()
     {
         refreshPrimaryKeys(aNames);
         refreshForeignKeys(aNames);
-        m_xKeys = createKeys(aNames);
+        m_xKeys.reset(createKeys(aNames));
     } // if(!isNew())
     else if (!m_xKeys )
-        m_xKeys = createKeys(aNames);
+        m_xKeys.reset(createKeys(aNames));
     /*if(m_pKeys)
         m_pKeys->reFill(aVector);
     else*/
@@ -460,7 +460,7 @@ void OTableHelper::refreshIndexes()
     if(m_xIndexes)
         m_xIndexes->reFill(aVector);
     else
-        m_xIndexes = createIndexes(aVector);
+        m_xIndexes.reset(createIndexes(aVector));
 }
 
 OUString OTableHelper::getRenameStart() const
diff --git a/connectivity/source/drivers/ado/ATable.cxx b/connectivity/source/drivers/ado/ATable.cxx
index 12280d9bc002..1ade9a649b77 100644
--- a/connectivity/source/drivers/ado/ATable.cxx
+++ b/connectivity/source/drivers/ado/ATable.cxx
@@ -90,7 +90,7 @@ void OAdoTable::refreshColumns()
     if(m_xColumns)
         m_xColumns->reFill(aVector);
     else
-        m_xColumns = new OColumns(*this,m_aMutex,aVector,aColumns,isCaseSensitive(),m_pCatalog->getConnection());
+        m_xColumns.reset(new OColumns(*this,m_aMutex,aVector,aColumns,isCaseSensitive(),m_pCatalog->getConnection()));
 }
 
 void OAdoTable::refreshKeys()
@@ -107,7 +107,7 @@ void OAdoTable::refreshKeys()
     if(m_xKeys)
         m_xKeys->reFill(aVector);
     else
-        m_xKeys = new OKeys(*this,m_aMutex,aVector,aKeys,isCaseSensitive(),m_pCatalog->getConnection());
+        m_xKeys.reset(new OKeys(*this,m_aMutex,aVector,aKeys,isCaseSensitive(),m_pCatalog->getConnection()));
 }
 
 void OAdoTable::refreshIndexes()
@@ -124,7 +124,7 @@ void OAdoTable::refreshIndexes()
     if(m_xIndexes)
         m_xIndexes->reFill(aVector);
     else
-        m_xIndexes = new OIndexes(*this,m_aMutex,aVector,aIndexes,isCaseSensitive(),m_pCatalog->getConnection());
+        m_xIndexes.reset(new OIndexes(*this,m_aMutex,aVector,aIndexes,isCaseSensitive(),m_pCatalog->getConnection()));
 }
 
 Sequence< sal_Int8 > OAdoTable::getUnoTunnelId()
diff --git a/connectivity/source/drivers/component/CTable.cxx b/connectivity/source/drivers/component/CTable.cxx
index 9b5354d266d1..83dbf8a68830 100644
--- a/connectivity/source/drivers/component/CTable.cxx
+++ b/connectivity/source/drivers/component/CTable.cxx
@@ -63,7 +63,7 @@ void OComponentTable::refreshColumns()
     if(m_xColumns)
         m_xColumns->reFill(aVector);
     else
-        m_xColumns = new component::OComponentColumns(this,m_aMutex,aVector);
+        m_xColumns.reset(new component::OComponentColumns(this,m_aMutex,aVector));
 }
 
 void OComponentTable::refreshIndexes()
diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx
index 899997062fe2..51ad6110ec44 100644
--- a/connectivity/source/drivers/dbase/DTable.cxx
+++ b/connectivity/source/drivers/dbase/DTable.cxx
@@ -468,7 +468,6 @@ ODbaseTable::ODbaseTable(sdbcx::OCollection* _pTables, ODbaseConnection* _pConne
     m_eEncoding = getConnection()->getTextEncoding();
 }
 
-
 void ODbaseTable::construct()
 {
     // initialize the header
@@ -658,7 +657,7 @@ void ODbaseTable::refreshColumns()
     if(m_xColumns)
         m_xColumns->reFill(aVector);
     else
-        m_xColumns = new ODbaseColumns(this,m_aMutex,aVector);
+        m_xColumns.reset(new ODbaseColumns(this,m_aMutex,aVector));
 }
 
 void ODbaseTable::refreshIndexes()
@@ -701,7 +700,7 @@ void ODbaseTable::refreshIndexes()
     if(m_xIndexes)
         m_xIndexes->reFill(aVector);
     else
-        m_xIndexes = new ODbaseIndexes(this,m_aMutex,aVector);
+        m_xIndexes.reset(new ODbaseIndexes(this,m_aMutex,aVector));
 }
 
 
@@ -1650,7 +1649,7 @@ bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, const OValueRefRow& pOrgRo
 
     ::comphelper::UStringMixEqual aCase(isCaseSensitive());
 
-    Reference<XIndexAccess> xColumns = m_xColumns;
+    Reference<XIndexAccess> xColumns(m_xColumns.get());
     // first search a key that exist already in the table
     for (sal_Int32 i = 0; i < nColumnCount; ++i)
     {
@@ -2516,7 +2515,7 @@ void ODbaseTable::copyData(ODbaseTable* _pNewTable,sal_Int32 _nPos)
                         }
                     }
                 }
-                bOk = _pNewTable->InsertRow(*aInsertRow,_pNewTable->m_xColumns);
+                bOk = _pNewTable->InsertRow(*aInsertRow, _pNewTable->m_xColumns.get());
                 SAL_WARN_IF(!bOk, "connectivity.drivers", "Row could not be inserted!");
             }
             else
diff --git a/connectivity/source/drivers/evoab2/NTable.cxx b/connectivity/source/drivers/evoab2/NTable.cxx
index b5c652a8ff67..efb3288dd226 100644
--- a/connectivity/source/drivers/evoab2/NTable.cxx
+++ b/connectivity/source/drivers/evoab2/NTable.cxx
@@ -70,7 +70,7 @@ void OEvoabTable::refreshColumns()
     if (m_xColumns)
         m_xColumns->reFill(aVector);
     else
-        m_xColumns = new OEvoabColumns(this,m_aMutex,aVector);
+        m_xColumns.reset(new OEvoabColumns(this,m_aMutex,aVector));
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/file/FTable.cxx b/connectivity/source/drivers/file/FTable.cxx
index d56b5f86f969..50475449ef73 100644
--- a/connectivity/source/drivers/file/FTable.cxx
+++ b/connectivity/source/drivers/file/FTable.cxx
@@ -86,7 +86,7 @@ void OFileTable::refreshColumns()
     if(m_xColumns)
         m_xColumns->reFill(aVector);
     else
-        m_xColumns = new OColumns(this,m_aMutex,aVector);
+        m_xColumns.reset(new OColumns(this,m_aMutex,aVector));
 }
 
 void OFileTable::refreshKeys()
diff --git a/connectivity/source/drivers/flat/ETable.cxx b/connectivity/source/drivers/flat/ETable.cxx
index ea47022d026f..7c47240c27c4 100644
--- a/connectivity/source/drivers/flat/ETable.cxx
+++ b/connectivity/source/drivers/flat/ETable.cxx
@@ -503,7 +503,7 @@ void OFlatTable::refreshColumns()
     if(m_xColumns)
         m_xColumns->reFill(aVector);
     else
-        m_xColumns = new OFlatColumns(this,m_aMutex,aVector);
+        m_xColumns.reset(new OFlatColumns(this,m_aMutex,aVector));
 }
 
 
diff --git a/connectivity/source/drivers/macab/MacabTable.cxx b/connectivity/source/drivers/macab/MacabTable.cxx
index 75da75bc1035..1133556b9dce 100644
--- a/connectivity/source/drivers/macab/MacabTable.cxx
+++ b/connectivity/source/drivers/macab/MacabTable.cxx
@@ -80,7 +80,7 @@ void MacabTable::refreshColumns()
     if (m_xColumns)
         m_xColumns->reFill(aVector);
     else
-        m_xColumns  = new MacabColumns(this,m_aMutex,aVector);
+        m_xColumns.reset(new MacabColumns(this, m_aMutex, aVector));
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/inc/dbase/DColumns.hxx b/connectivity/source/inc/dbase/DColumns.hxx
index 158994c2c900..dbbbbec90acc 100644
--- a/connectivity/source/inc/dbase/DColumns.hxx
+++ b/connectivity/source/inc/dbase/DColumns.hxx
@@ -38,7 +38,6 @@ namespace connectivity::dbase
                          ) : file::OColumns(_pTable,_rMutex,_rVector)
             {}
         };
-
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/sdbcx/VTable.cxx b/connectivity/source/sdbcx/VTable.cxx
index 98e2767259f7..7a28bc5f4289 100644
--- a/connectivity/source/sdbcx/VTable.cxx
+++ b/connectivity/source/sdbcx/VTable.cxx
@@ -164,7 +164,7 @@ Reference< XNameAccess > SAL_CALL OTable::getColumns(  )
         // allowed
     }
 
-    return m_xColumns;
+    return m_xColumns.get();
 }
 
 
@@ -236,7 +236,7 @@ Reference< XNameAccess > SAL_CALL OTable::getIndexes(  )
         // allowed
     }
 
-    return m_xIndexes;
+    return m_xIndexes.get();
 }
 
 // XRename
diff --git a/dbaccess/source/core/api/RowSet.hxx b/dbaccess/source/core/api/RowSet.hxx
index 33a1aceaa4c5..6da5fdb2ece1 100644
--- a/dbaccess/source/core/api/RowSet.hxx
+++ b/dbaccess/source/core/api/RowSet.hxx
@@ -100,6 +100,7 @@ namespace dbaccess
 
         ::dbtools::WarningsContainer                m_aWarnings;
 
+        // no Reference! see OCollection::acquire
         std::unique_ptr<OTableContainer>       m_xTables;
 
         OUString                               m_aCommand;
diff --git a/include/connectivity/sdbcx/VTable.hxx b/include/connectivity/sdbcx/VTable.hxx
index 919626681064..4d9b48c92835 100644
--- a/include/connectivity/sdbcx/VTable.hxx
+++ b/include/connectivity/sdbcx/VTable.hxx
@@ -73,9 +73,10 @@ namespace connectivity::sdbcx
             OUString m_Description;
             OUString m_Type;
 
-            rtl::Reference<OCollection>  m_xKeys;
-            rtl::Reference<OCollection>  m_xColumns;
-            rtl::Reference<OCollection>  m_xIndexes;
+            // no Reference! see OCollection::acquire
+            std::unique_ptr<OCollection> m_xKeys;
+            std::unique_ptr<OCollection> m_xColumns;
+            std::unique_ptr<OCollection> m_xIndexes;
             OCollection*    m_pTables;  // must hold his own container to notify him when renaming
 
             using OTableDescriptor_BASE::rBHelper;


More information about the Libreoffice-commits mailing list