writerfilter/source/dmapper/TableManager.cxx |    6 ++++++
 1 file changed, 6 insertions(+)

New commits:
commit edc53ec766993b0b7910e87b3765d720565191d6
Author:     Justin Luth <jl...@mail.com>
AuthorDate: Fri Jul 23 17:12:05 2021 +0200
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Wed Aug 4 12:33:33 2021 +0200

    crashreport writerfilter: findColumn(unsigned long,unsigned long)
    
    Although the crash reports don't show getRow as a separate
    item in the list of functions leading to the crash,
    it just CAN'T be a problem with mTableDataStack.empty()
    or !mTableDataStack.top() because they are unconditionally
    used or popped later on in endLevel().
    
    So I resisted the urge to test everything, and just verified
    that the row (which exists for m_aCellProperties) actually
    exists in the table manager - similar to getGridBefore().
    
    Change-Id: I5a27dc40db18f05ad4656789d3e61ec1ff4de471
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119420
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <justin_l...@sil.org>
    (cherry picked from commit 82b14219969c4f80d421015c9e89e8d3db4650d8)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119616
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/writerfilter/source/dmapper/TableManager.cxx 
b/writerfilter/source/dmapper/TableManager.cxx
index ea71e887adb3..ce1d550d8e55 100644
--- a/writerfilter/source/dmapper/TableManager.cxx
+++ b/writerfilter/source/dmapper/TableManager.cxx
@@ -93,6 +93,9 @@ void TableManager::setCurrentGridSpan(sal_uInt32 nGridSpan, 
bool bFirstCell)
 
 sal_uInt32 TableManager::findColumn(const sal_uInt32 nRow, const sal_uInt32 
nCell)
 {
+    if (nRow >= mTableDataStack.top()->getRowCount())
+        return SAL_MAX_UINT32;
+
     RowData::Pointer_t pRow = mTableDataStack.top()->getRow(nRow);
     if (!pRow || nCell < pRow->getGridBefore()
         || nCell >= pRow->getCellCount() - pRow->getGridAfter())
@@ -110,6 +113,9 @@ sal_uInt32 TableManager::findColumn(const sal_uInt32 nRow, 
const sal_uInt32 nCel
 
 sal_uInt32 TableManager::findColumnCell(const sal_uInt32 nRow, const 
sal_uInt32 nCol)
 {
+    if (nRow >= mTableDataStack.top()->getRowCount())
+        return SAL_MAX_UINT32;
+
     RowData::Pointer_t pRow = mTableDataStack.top()->getRow(nRow);
     if (!pRow || nCol < pRow->getGridBefore())
         return SAL_MAX_UINT32;

Reply via email to