diff options
author | Lionel Elie Mamane <lionel@mamane.lu> | 2012-06-01 11:42:53 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-06-05 12:14:29 +0100 |
commit | 38786a76cf3dbc421635d40354e8c9ece409c6c5 (patch) | |
tree | afca64c3548dc50b472fb891ca5755218f50873a | |
parent | 5ae8cb8fc0d7ae3c85ccf23ffb8e2a890728cb72 (diff) |
fdo#50372: crash when refresh of last already-known row unexpectedly fails
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
-rw-r--r-- | 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 74b8b17a7e14..881da4050202 100644 --- a/dbaccess/source/core/api/KeySet.cxx +++ b/dbaccess/source/core/api/KeySet.cxx @@ -1375,10 +1375,23 @@ void SAL_CALL OKeySet::refreshRow() throw(SQLException, RuntimeException) sal_Bool bOK = m_xSet->next(); 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 |