diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-03-17 14:51:06 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-03-17 14:51:27 +0000 |
commit | 4331b137fdbe6992ca63ceb70a6f48ed6f9a86ea (patch) | |
tree | 1226cfec74a178af2ae2452f41883321bf6e5fdb /dbaccess | |
parent | f1aca4db8bd82e8beefeccc8e12c752f686133ee (diff) |
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
Diffstat (limited to 'dbaccess')
-rw-r--r-- | dbaccess/source/core/api/RowSet.cxx | 27 | ||||
-rw-r--r-- | dbaccess/source/core/api/RowSet.hxx | 1 |
2 files changed, 27 insertions, 1 deletions
diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx index 74d3e793ecdd..bbf65484d93d 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 e06bcb62a089..058b85dfb6f1 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 ; |