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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Jan 30 08:18:17 UTC 2019


 sw/source/filter/writer/wrtswtbl.cxx |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit f1f84cf7fae3c777908cfc5357a067db731367ac
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Tue Jan 29 13:44:07 2019 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Jan 30 09:17:53 2019 +0100

    Avoid computing negative nColSpan
    
    With Clang -fsanitize=implicit-signed-integer-truncation,
    CppunitTest_sw_ooxmlexport8 fails with
    
    > sw/source/filter/writer/wrtswtbl.cxx:666:39: runtime error: implicit conversion from type 'int' of value -1 (32-bit, signed) to type 'sal_uInt16' (aka 'unsigned short') changed the value to 65535 (16-bit, unsigned)
    >  #0 in SwWriteTable::FillTableRowsCols(long, unsigned short, unsigned int, unsigned short, long, unsigned int, SwTableLines const&, SvxBrushItem const*, unsigned short, unsigned short) at sw/source/filter/writer/wrtswtbl.cxx:666:39
    >  #1 in SwWriteTable::SwWriteTable(SwTable const*, SwTableLines const&, long, unsigned int, bool, unsigned short, unsigned short, unsigned short, unsigned int) at sw/source/filter/writer/wrtswtbl.cxx:757:5
    >  #2 in DocxAttributeOutput::InitTableHelper(std::shared_ptr<ww8::WW8TableNodeInfoInner> const&) at sw/source/filter/ww8/docxattributeoutput.cxx:3481:31
    >  #3 in DocxAttributeOutput::FinishTableRowCell(std::shared_ptr<ww8::WW8TableNodeInfoInner> const&, bool) at sw/source/filter/ww8/docxattributeoutput.cxx:907:9
    >  #4 in DocxAttributeOutput::TableNodeInfoInner(std::shared_ptr<ww8::WW8TableNodeInfoInner>) at sw/source/filter/ww8/docxattributeoutput.cxx:4248:5
    >  #5 in MSWordExportBase::OutputStartNode(SwStartNode const&) at sw/source/filter/ww8/wrtww8.cxx:4167:26
    >  #6 in MSWordExportBase::WriteText() at sw/source/filter/ww8/wrtww8.cxx:2812:13
    >  #7 in DocxAttributeOutput::WriteFloatingTable(ww8::Frame const*) at sw/source/filter/ww8/docxattributeoutput.cxx:336:17
    >  #8 in checkAndWriteFloatingTables(DocxAttributeOutput&) at sw/source/filter/ww8/docxattributeoutput.cxx:396:30
    >  #9 in DocxAttributeOutput::StartParagraph(std::shared_ptr<ww8::WW8TableNodeInfo>) at sw/source/filter/ww8/docxattributeoutput.cxx:406:9
    >  #10 in MSWordExportBase::OutputTextNode(SwTextNode&) at sw/source/filter/ww8/wrtw8nds.cxx:2181:22
    >  #11 in MSWordExportBase::OutputContentNode(SwContentNode&) at sw/source/filter/ww8/wrtw8nds.cxx:3327:13
    >  #12 in MSWordExportBase::WriteText() at sw/source/filter/ww8/wrtww8.cxx:2727:13
    >  #13 in DocxExport::WriteMainText() at sw/source/filter/ww8/docxexport.cxx:1469:5
    >  #14 in DocxExport::ExportDocument_Impl() at sw/source/filter/ww8/docxexport.cxx:527:5
    >  #15 in MSWordExportBase::ExportDocument(bool) at sw/source/filter/ww8/wrtww8.cxx:3212:19
    >  #16 in DocxExportFilter::exportDocument() at sw/source/filter/ww8/docxexportfilter.cxx:86:17
    >  #17 in oox::core::FilterBase::filter(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) at oox/source/core/filterbase.cxx:497:55
    >  #18 in WriterFilter::filter(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) at writerfilter/source/filter/WriterFilter.cxx:149:23
    >  #19 in SfxObjectShell::ExportTo(SfxMedium&) at sfx2/source/doc/objstor.cxx:2411:25
    >  #20 in SfxObjectShell::SaveTo_Impl(SfxMedium&, SfxItemSet const*) at sfx2/source/doc/objstor.cxx:1505:19
    >  #21 in SfxObjectShell::PreDoSaveAs_Impl(rtl::OUString const&, rtl::OUString const&, SfxItemSet const&) at sfx2/source/doc/objstor.cxx:2818:39
    >  #22 in SfxObjectShell::CommonSaveAs_Impl(INetURLObject const&, rtl::OUString const&, SfxItemSet&) at sfx2/source/doc/objstor.cxx:2675:9
    >  #23 in SfxObjectShell::APISaveAs_Impl(rtl::OUString const&, SfxItemSet&) at sfx2/source/doc/objserv.cxx:321:19
    >  #24 in SfxBaseModel::impl_store(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, bool) at sfx2/source/doc/sfxbasemodel.cxx:3001:46
    >  #25 in SfxBaseModel::storeToURL(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) at sfx2/source/doc/sfxbasemodel.cxx:1672:13
    >  #26 in SwModelTestBase::reload(char const*, char const*, char const*) at sw/qa/extras/inc/swmodeltestbase.hxx:796:20
    >  #27 in SwModelTestBase::executeImportExportImportTest(char const*, char const*) at sw/qa/extras/inc/swmodeltestbase.hxx:283:9
    >  #28 in testN779642::Import_Export_Import() at sw/qa/extras/ooxmlexport/ooxmlexport8.cxx:746:1
    
    (where nCPos is 23, nOldCol is 2, and nCol is 0).
    
    sw/qa/extras/ooxmlexport/data/n779642.docx processed by that testN779642 is the
    only case during `make check` for which the added SAL_WARN_IF triggers.  That
    file was added with 874f0a1be443b8027d5aba2285866f31cf4169e5 "n#779642: ignore
    framePr inside table or the table import won't work", leaving its origin
    unclear, and trying to open it with at least MS Word for Mac version 16.21 fails
    with "could not be opened", so it looks somewhat plausible that computation of
    such negative spans should just not happen.
    
    Change-Id: I0d460d04050017f7793ae51dc2a51ebbd3c4c193
    Reviewed-on: https://gerrit.libreoffice.org/67075
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/sw/source/filter/writer/wrtswtbl.cxx b/sw/source/filter/writer/wrtswtbl.cxx
index 698f4df38c19..b3a17155a90e 100644
--- a/sw/source/filter/writer/wrtswtbl.cxx
+++ b/sw/source/filter/writer/wrtswtbl.cxx
@@ -663,7 +663,8 @@ void SwWriteTable::FillTableRowsCols( long nStartRPos, sal_uInt16 nStartRow,
                 else if ( nAttrRowSpan < 1 )
                     nRowSpan = 0;
 
-                sal_uInt16 nColSpan = nCol - nOldCol + 1;
+                SAL_WARN_IF(nCol < nOldCol, "sw.filter", "unexpected " << nCol << " < " << nOldCol);
+                sal_uInt16 nColSpan = nCol >= nOldCol ? nCol - nOldCol + 1 : 1;
                 pRow->AddCell( pBox, nOldRow, nOldCol,
                                nRowSpan, nColSpan, nHeight,
                                pBrushItem );


More information about the Libreoffice-commits mailing list