From 2c52969d3d2ea8d8dcbbb017497eccda0d459266 Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Fri, 23 Jul 2021 17:12:05 +0200 Subject: crashreport writerfilter: findColumn(unsigned long,unsigned long) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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(). These functions were added via tdf#129452 writerfilter: use column, not cell when comparing rows 7.1 commit 19d7f9624e92422409ed2744091d502fdae8692b The crash report did not identify any example documents or reproducable steps, so no unit test was possible. Change-Id: I5a27dc40db18f05ad4656789d3e61ec1ff4de471 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119420 Tested-by: Jenkins Reviewed-by: Justin Luth (cherry picked from commit 82b14219969c4f80d421015c9e89e8d3db4650d8) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119616 Reviewed-by: Caolán McNamara (cherry picked from commit edc53ec766993b0b7910e87b3765d720565191d6) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119979 --- writerfilter/source/dmapper/TableManager.cxx | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'writerfilter') 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; -- cgit