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

Caolán McNamara caolanm at redhat.com
Thu Mar 17 14:53:55 UTC 2016


 dbaccess/source/core/api/RowSet.cxx |   27 ++++++++++++++++++++++++++-
 dbaccess/source/core/api/RowSet.hxx |    1 +
 2 files changed, 27 insertions(+), 1 deletion(-)

New commits:
commit 4331b137fdbe6992ca63ceb70a6f48ed6f9a86ea
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Mar 17 14:51:06 2016 +0000

    Resolves: tdf#92617 don't crash if insertRow gets triggered during insertRow
    
    insertRow notifies listeners that it is going to insert contents,
    if a script listens to that and eventually triggers insertRow again then
    one inside the other causes corruption and pestilence
    
    Change-Id: I6b568d0a67f6108536d58c407b79d02bf29f297a

diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx
index 74d3e79..bbf6548 100644
--- a/dbaccess/source/core/api/RowSet.cxx
+++ b/dbaccess/source/core/api/RowSet.cxx
@@ -148,6 +148,7 @@ ORowSet::ORowSet( const Reference< css::uno::XComponentContext >& _rxContext )
     ,m_nPrivileges(0)
     ,m_nLastKnownRowCount(0)
     ,m_nInAppend(0)
+    ,m_bInsertingRow(false)
     ,m_bLastKnownRowCountFinal(false)
     ,m_bUseEscapeProcessing(true)
     ,m_bApplyFilter(false)
@@ -861,9 +862,33 @@ void SAL_CALL ORowSet::updateNumericObject( sal_Int32 columnIndex, const Any& x,
     aNotify.firePropertyChange();
 }
 
+namespace
+{
+    class ProtectFlag
+    {
+        bool& m_rInsertingRow;
+    public:
+        ProtectFlag(bool& rInsertingRow)
+            : m_rInsertingRow(rInsertingRow)
+        {
+            if (m_rInsertingRow)
+            {
+                throw std::runtime_error("recursion in insertRow");
+            }
+            m_rInsertingRow = true;
+        }
+        ~ProtectFlag()
+        {
+            m_rInsertingRow = false;
+        }
+    };
+}
+
 // XResultSetUpdate
-void SAL_CALL ORowSet::insertRow(  ) throw(SQLException, RuntimeException, std::exception)
+void SAL_CALL ORowSet::insertRow() throw(SQLException, RuntimeException, std::exception)
 {
+    ProtectFlag aFlagControl(m_bInsertingRow);
+
     ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed);
     // insertRow is not allowed when
     // standing not on the insert row nor
diff --git a/dbaccess/source/core/api/RowSet.hxx b/dbaccess/source/core/api/RowSet.hxx
index e06bcb6..058b85d 100644
--- a/dbaccess/source/core/api/RowSet.hxx
+++ b/dbaccess/source/core/api/RowSet.hxx
@@ -124,6 +124,7 @@ namespace dbaccess
         sal_Int32                   m_nPrivileges;
         sal_Int32                   m_nLastKnownRowCount;
         oslInterlockedCount         m_nInAppend;
+        bool                        m_bInsertingRow;
         bool                        m_bLastKnownRowCountFinal;
         bool                        m_bUseEscapeProcessing ;
         bool                        m_bApplyFilter ;


More information about the Libreoffice-commits mailing list