diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2025-02-06 08:35:33 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2025-02-08 10:03:21 +0100 |
commit | 22af804836df3fc1827a2a08b2c91bd76b740177 (patch) | |
tree | 863c64a91195436fcd492d78eb2382b30e7a546d | |
parent | 65a518b5f0f23a145755c4fb7dd46c8246f0533e (diff) |
writerfilter: fix crash in DomainMapperTableHandler::endTable()
Crashreport signature:
/opt/rh/devtoolset-12/root/usr/include/c++/12/bits/stl_stack.h:234: std::stack<_Tp, _Sequence>::reference std::stack<_Tp, _Sequence>::top() [with _Tp = writerfilter::dmapper::TextAppendContext; _Sequence = std::deque<writerfilter::dmapper::TextAppendContext, std::allocator<writerfilter::dmapper::TextAppendContext> >; reference = writerfilter::dmapper::TextAppendContext&]: Assertion '!this->empty()' failed.
SIG Fatal signal received: SIGABRT code: 18446744073709551610 for address: 0x7300004d65
program/libwriterfilterlo.so
writerfilter::dmapper::DomainMapper_Impl::GetTopTextAppend()
/opt/rh/devtoolset-12/root/usr/include/c++/12/bits/stl_stack.h:234
program/libwriterfilterlo.so
writerfilter::dmapper::DomainMapperTableHandler::endTable(unsigned int)
workdir/UnoApiHeadersTarget/offapi/normal/com/sun/star/text/XTextAppendAndConvert.hpp:23
program/libwriterfilterlo.so
writerfilter::dmapper::TableManager::resolveCurrentTable()
include/tools/ref.hxx:56
program/libwriterfilterlo.so
writerfilter::dmapper::TableManager::endLevel()
writerfilter/source/dmapper/TableManager.cxx:461
It seems the trouble is that DomainMapperTableHandler::endTable() calls
GetTopTextAppend() unconditionally, which asserts that the text append
stack is non-empty. GetCurrentXText() already check if this stack is
empty, so use that to check for emptyness and only then get the top of
the stack. Later DomainMapperTableHandler::endTable() already checks if
xTextAppendAndConvert is an empty reference or not.
Change-Id: Ibb377cb03f8beaed9b3c9d45e322c8ad1f9d26c3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181205
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com>
-rw-r--r-- | writerfilter/source/dmapper/DomainMapperTableHandler.cxx | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx index 5ebe9c8b77a9..6cc69a01a83a 100644 --- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx @@ -1660,7 +1660,11 @@ void DomainMapperTableHandler::endTable(unsigned int nestedTableLevel) sal_Int32 nTableWidthType = text::SizeType::FIX; m_aTableProperties->getValue(TablePropertyMap::TABLE_WIDTH_TYPE, nTableWidthType); // m_xText points to the body text, get the current xText from m_rDMapper_Impl, in case e.g. we would be in a header. - uno::Reference<text::XTextAppendAndConvert> xTextAppendAndConvert(m_rDMapper_Impl.GetTopTextAppend(), uno::UNO_QUERY); + uno::Reference<text::XTextAppendAndConvert> xTextAppendAndConvert; + if (m_rDMapper_Impl.GetCurrentXText()) + { + xTextAppendAndConvert.set(m_rDMapper_Impl.GetTopTextAppend(), uno::UNO_QUERY); + } uno::Reference<beans::XPropertySet> xFrameAnchor; // Writer layout has problems with redlines on floating table rows in footnotes, avoid |