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

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Mon Nov 23 13:06:24 UTC 2020


 dbaccess/source/core/api/RowSetBase.cxx |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

New commits:
commit bd5806591b29b7cb9127c96b49d920c4281c37c8
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Nov 23 10:04:38 2020 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Nov 23 14:05:44 2020 +0100

    Resolves: rhbz#1900428 don't crash on invalid index used in StarBasic macro
    
    Change-Id: I05064f7e9216c9c43b49950b309afe72466857a6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106401
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/dbaccess/source/core/api/RowSetBase.cxx b/dbaccess/source/core/api/RowSetBase.cxx
index bc4b81b7a46d..4eabb3eb0bee 100644
--- a/dbaccess/source/core/api/RowSetBase.cxx
+++ b/dbaccess/source/core/api/RowSetBase.cxx
@@ -231,11 +231,16 @@ const ORowSetValue& ORowSetBase::impl_getValue(sal_Int32 columnIndex)
             OSL_ENSURE( pTemp != reinterpret_cast<void*>(0xfeeefeee),"HALT!" );
         }
         OSL_ENSURE(!m_aCurrentRow.isNull() && m_aCurrentRow < m_pCache->getEnd() && aCacheIter != m_pCache->m_aCacheIterators.end(),"Invalid iterator set for currentrow!");
-        ORowSetRow rRow = *m_aCurrentRow;
-        OSL_ENSURE(rRow.is() && o3tl::make_unsigned(columnIndex) < rRow->size(),"Invalid size of vector!");
 #endif
+        ORowSetRow rRow = *m_aCurrentRow;
+        bool bValidPosition = rRow.is() && o3tl::make_unsigned(columnIndex) < rRow->size();
+        if (!bValidPosition)
+        {
+            SAL_WARN("dbaccess", "ORowSetBase::getValue: Invalid size of vector!");
+            ::dbtools::throwSQLException( DBA_RES( RID_STR_CURSOR_BEFORE_OR_AFTER ), StandardSQLState::INVALID_CURSOR_POSITION, *m_pMySelf );
+        }
         m_nLastColumnIndex = columnIndex;
-        return (**m_aCurrentRow)[m_nLastColumnIndex];
+        return (*rRow)[m_nLastColumnIndex];
     }
 
     // we should normally never reach this


More information about the Libreoffice-commits mailing list