sw/source/filter/ww8/docxattributeoutput.cxx | 29 ++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-)
New commits: commit 5d48602bfc2083294fc7d6a370bae4ce689be59e Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Tue Sep 27 09:11:03 2022 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Tue Sep 27 11:14:31 2022 +0200 crashtesting: crash in DocxAttributeOutput::TableCellProperties on converting ooo59560-1.sxw to docx Change-Id: I616b254c83ae168806f08a80c07b14de696cc87b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140642 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 5833dd62dbca..b4b19cff7088 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -4199,15 +4199,20 @@ void DocxAttributeOutput::TableCellProperties( ww8::WW8TableNodeInfoInner::Point // Horizontal spans const SwWriteTableRows& rRows = m_xTableWrt->GetRows( ); - SwWriteTableRow *pRow = rRows[ nRow ].get(); - const SwWriteTableCells& rTableCells = pRow->GetCells(); - if (nCell < rTableCells.size() ) + if (nRow >= rRows.size()) + SAL_WARN("sw.ww8", "DocxAttributeOutput::TableCellProperties: out of range row: " << nRow); + else { - const SwWriteTableCell& rCell = *rTableCells[nCell]; - const sal_uInt16 nColSpan = rCell.GetColSpan(); - if ( nColSpan > 1 ) - m_pSerializer->singleElementNS( XML_w, XML_gridSpan, - FSNS( XML_w, XML_val ), OString::number(nColSpan) ); + SwWriteTableRow *pRow = rRows[ nRow ].get(); + const SwWriteTableCells& rTableCells = pRow->GetCells(); + if (nCell < rTableCells.size() ) + { + const SwWriteTableCell& rCell = *rTableCells[nCell]; + const sal_uInt16 nColSpan = rCell.GetColSpan(); + if ( nColSpan > 1 ) + m_pSerializer->singleElementNS( XML_w, XML_gridSpan, + FSNS( XML_w, XML_val ), OString::number(nColSpan) ); + } } // Vertical merges @@ -5086,7 +5091,13 @@ void DocxAttributeOutput::TableVerticalCell( ww8::WW8TableNodeInfoInner::Pointer } const SwWriteTableRows& rRows = m_xTableWrt->GetRows( ); - SwWriteTableRow *pRow = rRows[ pTableTextNodeInfoInner->getRow( ) ].get(); + const auto nRow = pTableTextNodeInfoInner->getRow(); + if (nRow >= rRows.size()) + { + SAL_WARN("sw.ww8", "DocxAttributeOutput::TableCellProperties: out of range row: " << nRow); + return; + } + SwWriteTableRow *pRow = rRows[nRow].get(); sal_uInt32 nCell = pTableTextNodeInfoInner->getCell(); const SwWriteTableCells& rTableCells = pRow->GetCells(); if (nCell >= rTableCells.size() )