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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Nov 12 20:14:05 UTC 2018


 sw/source/filter/ww8/wrtww8.cxx |    4 ++--
 sw/source/filter/ww8/wrtww8.hxx |    1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

New commits:
commit a1f23b1fc4814bb857bb433570ed25c11594d583
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Mon Nov 12 19:29:59 2018 +0100
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Mon Nov 12 21:13:43 2018 +0100

    Silence -fsanitize=implicit-signed-integer-truncation
    
    ...as happens during CppunitTest_sw_ww8export (see below), by keeping
    nTableOffset of signed type.
    
    It is beneficial to introduce InsInt16 (internally doing the cast to sal_uInt16)
    instead of casting nTableOffset to sal_uInt16 at the call site, so that
    -fsanitize=implicit-signed-integer-truncation can still warn about bad
    nTableOffset values outside the sal_Int16 range being passed to InsInt16.
    
    > sw/source/filter/ww8/wrtww8.cxx:2392:34: runtime error: implicit conversion from type 'int' of value 67140 (32-bit, signed) to type 'sal_uInt16' (aka 'unsigned short') changed the value to 1604 (16-bit, unsigned)
    >  #0 in WW8AttributeOutput::TableDefinition(std::shared_ptr<ww8::WW8TableNodeInfoInner>) at sw/source/filter/ww8/wrtww8.cxx:2392:34 (instdir/program/libmswordlo.so +0x1f12f98)
    >  #1 in WW8AttributeOutput::TableInfoRow(std::shared_ptr<ww8::WW8TableNodeInfoInner>) at sw/source/filter/ww8/wrtww8.cxx:2058:13 (instdir/program/libmswordlo.so +0x1f06ccf)
    >  #2 in WW8AttributeOutput::EndParagraph(std::shared_ptr<ww8::WW8TableNodeInfoInner>) at sw/source/filter/ww8/ww8atr.cxx:998:13 (instdir/program/libmswordlo.so +0x208fe56)
    >  #3 in MSWordExportBase::OutputTextNode(SwTextNode&) at sw/source/filter/ww8/wrtw8nds.cxx:2966:22 (instdir/program/libmswordlo.so +0x1c4d259)
    >  #4 in MSWordExportBase::OutputContentNode(SwContentNode&) at sw/source/filter/ww8/wrtw8nds.cxx:3237:13 (instdir/program/libmswordlo.so +0x1c5a3b4)
    >  #5 in MSWordExportBase::WriteText() at sw/source/filter/ww8/wrtww8.cxx:2725:13 (instdir/program/libmswordlo.so +0x1efa992)
    >  #6 in WW8Export::WriteMainText() at sw/source/filter/ww8/wrtww8.cxx:2845:5 (instdir/program/libmswordlo.so +0x1f2101e)
    >  #7 in WW8Export::StoreDoc1() at sw/source/filter/ww8/wrtww8.cxx:3005:5 (instdir/program/libmswordlo.so +0x1f31acf)
    >  #8 in WW8Export::ExportDocument_Impl() at sw/source/filter/ww8/wrtww8.cxx:3367:5 (instdir/program/libmswordlo.so +0x1f46dd2)
    >  #9 in MSWordExportBase::ExportDocument(bool) at sw/source/filter/ww8/wrtww8.cxx:3206:19 (instdir/program/libmswordlo.so +0x1f3cbf2)
    >  #10 in SwWW8Writer::WriteStorage() at sw/source/filter/ww8/wrtww8.cxx:3545:23 (instdir/program/libmswordlo.so +0x1f50966)
    >  #11 in StgWriter::Write(SwPaM&, SotStorage&, rtl::OUString const*) at sw/source/filter/writer/writer.cxx:511:20 (instdir/program/libswlo.so +0xcc770c4)
    >  #12 in Writer::Write(SwPaM&, SvStream&, rtl::OUString const*) at sw/source/filter/writer/writer.cxx:254:23 (instdir/program/libswlo.so +0xcc6cc1f)
    >  #13 in Writer::Write(SwPaM&, SfxMedium&, rtl::OUString const*) at sw/source/filter/writer/writer.cxx:289:12 (instdir/program/libswlo.so +0xcc6e1cc)
    >  #14 in SwWW8Writer::Write(SwPaM&, SfxMedium&, rtl::OUString const*) at sw/source/filter/ww8/wrtww8.cxx:3562:31 (instdir/program/libmswordlo.so +0x1f513ff)
    >  #15 in SwWriter::Write(tools::SvRef<Writer> const&, rtl::OUString const*) at sw/source/filter/basflt/shellio.cxx:851:28 (instdir/program/libswlo.so +0xc56906f)
    >  #16 in SwDocShell::ConvertTo(SfxMedium&) at sw/source/uibase/app/docsh.cxx:813:27 (instdir/program/libswlo.so +0xd038645)
    >  #17 in SfxObjectShell::SaveTo_Impl(SfxMedium&, SfxItemSet const*) at sfx2/source/doc/objstor.cxx:1537:19 (instdir/program/libsfxlo.so +0x38c0383)
    >  #18 in SfxObjectShell::PreDoSaveAs_Impl(rtl::OUString const&, rtl::OUString const&, SfxItemSet const&) at sfx2/source/doc/objstor.cxx:2848:39 (instdir/program/libsfxlo.so +0x38ef860)
    >  #19 in SfxObjectShell::CommonSaveAs_Impl(INetURLObject const&, rtl::OUString const&, SfxItemSet&) at sfx2/source/doc/objstor.cxx:2705:9 (instdir/program/libsfxlo.so +0x38e8e40)
    >  #20 in SfxObjectShell::APISaveAs_Impl(rtl::OUString const&, SfxItemSet&) at sfx2/source/doc/objserv.cxx:308:19 (instdir/program/libsfxlo.so +0x38651b3)
    >  #21 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:2969:46 (instdir/program/libsfxlo.so +0x3a3ae5e)
    >  #22 in SfxBaseModel::storeToURL(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) at sfx2/source/doc/sfxbasemodel.cxx:1639:13 (instdir/program/libsfxlo.so +0x3a40fa5)
    >  #23 in SwModelTestBase::reload(char const*, char const*, char const*) at sw/qa/extras/inc/swmodeltestbase.hxx:797:20 (workdir/LinkTarget/CppunitTest/libtest_sw_ww8export.so +0x3b3fb1)
    >  #24 in SwModelTestBase::executeImportExportImportTest(char const*, char const*) at sw/qa/extras/inc/swmodeltestbase.hxx:283:9 (workdir/LinkTarget/CppunitTest/libtest_sw_ww8export.so +0x3b25a8)
    >  #25 in testN760294::Import_Export_Import() at sw/qa/extras/ww8export/ww8export.cxx:133:1 (workdir/LinkTarget/CppunitTest/libtest_sw_ww8export.so +0x3c556d)
    [...]
    
    Change-Id: I673a96e9f7d2d1bdf40de20f3810c4986c338c93
    Reviewed-on: https://gerrit.libreoffice.org/63301
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index cd4fd16f8534..f0ab7e1ed7c4 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -2350,7 +2350,7 @@ void WW8AttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t
     const SwFormatHoriOrient &rHori = pFormat->GetHoriOrient();
     const SwFormatVertOrient &rVert = pFormat->GetVertOrient();
 
-    sal_uInt16 nTableOffset = 0;
+    SwTwips nTableOffset = 0;
 
     if (
         (text::RelOrientation::PRINT_AREA == rHori.GetRelationOrient() ||
@@ -2384,7 +2384,7 @@ void WW8AttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t
         }
     }
 
-     m_rWW8Export.InsUInt16( nTableOffset );
+     m_rWW8Export.InsInt16( nTableOffset );
 
     ww8::GridColsPtr pGridCols = GetGridCols( pTableTextNodeInfoInner );
     for ( const auto nCol : *pGridCols )
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index 5f4d441aa5b5..0766d4df2c39 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -1122,6 +1122,7 @@ public:
         const ww8::Frame &rFrameFormat);
 
     void InsUInt16( sal_uInt16 n )      { SwWW8Writer::InsUInt16( *pO, n ); }
+    void InsInt16(sal_Int16 n) { InsUInt16(sal_uInt16(n)); }
     void InsUInt32( sal_uInt32 n )      { SwWW8Writer::InsUInt32( *pO, n ); }
     void WriteStringAsPara( const OUString& rText );
 


More information about the Libreoffice-commits mailing list