[PATCH] fdo#50372: crash when refresh of last already-known row unexpectedly fails

Lionel Elie Mamane lionel at mamane.lu
Fri Jun 1 02:42:53 PDT 2012


Instead, try to do the least unreasonable thing:
Fetch a new row
If that fails because no new row to fetch, at least we are properly positioned after last row. Calling code may not expect that and get confused, but that is the best we can do.

Change-Id: Ib7248e99ae3deee8344e9386cac2c9440e8bccd8
---
 dbaccess/source/core/api/KeySet.cxx |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx
index cb65fff..101e4a7 100644
--- a/dbaccess/source/core/api/KeySet.cxx
+++ b/dbaccess/source/core/api/KeySet.cxx
@@ -1345,10 +1345,23 @@ void SAL_CALL OKeySet::refreshRow() throw(SQLException, RuntimeException)
     sal_Bool bOK = doTryRefetch_throw();
     if ( !bOK )
     {
+        // This row has disappeared; remove it.
         OKeySetMatrix::iterator aTemp = m_aKeyIter;
+        // use *next* row
         ++m_aKeyIter;
         m_aKeyMap.erase(aTemp);
-        --m_rRowCount;
+
+        // adjust RowCount for the row we have removed
+        if (m_rRowCount > 0)
+            --m_rRowCount;
+        else
+            OSL_FAIL("m_rRowCount got out of sync: non-empty m_aKeyMap, but m_rRowCount <= 0");
+
+        if (!isAfterLast())
+        {
+            // it was the last row, but there may be another one to fetch
+            fetchRow();
+        }
         refreshRow();
     }
     else
-- 
1.7.7.3


--9zSXsLTf0vkW971A--


More information about the LibreOffice mailing list