Kaydet (Commit) dec6bb21 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Don't truncate SCROW (aka sal_Int32) to sal_Int16

This looks like it was forgotten when changing other types to sal_[u]Int32 in
6bda3610 "Fixed binary import/export of
formulas", and now started to cause a
-fsanitize=implicit-signed-integer-truncation failure during
CppunitTest_sc_subsequent_export_test:

> sc/source/filter/excel/xeformula.cxx:1878:32: runtime error: implicit conversion from type 'sal_Int32' (aka 'int') of value 1048575 (32-bit, signed) to type 'sal_Int16' (aka 'short') changed the value to -1 (16-bit, signed)
>  #0 in XclExpFmlaCompImpl::ConvertRefData(ScSingleRefData&, XclAddress&, bool, bool, bool) const at sc/source/filter/excel/xeformula.cxx:1878:32 (instdir/program/libscfiltlo.so +0x3c936f4)
>  #1 in XclExpFmlaCompImpl::ConvertRefData(ScComplexRefData&, XclRange&, bool) const at sc/source/filter/excel/xeformula.cxx:1905:5 (instdir/program/libscfiltlo.so +0x3c944ee)
>  #2 in XclExpFmlaCompImpl::ProcessRangeRef((anonymous namespace)::XclExpScToken const&) at sc/source/filter/excel/xeformula.cxx:1981:5 (instdir/program/libscfiltlo.so +0x3ccba48)
>  #3 in XclExpFmlaCompImpl::Factor((anonymous namespace)::XclExpScToken) at sc/source/filter/excel/xeformula.cxx:1152:37 (instdir/program/libscfiltlo.so +0x3cc6f6c)
>  #4 in XclExpFmlaCompImpl::RangeTerm((anonymous namespace)::XclExpScToken, bool&) at sc/source/filter/excel/xeformula.cxx:1130:16 (instdir/program/libscfiltlo.so +0x3cc5d18)
>  #5 in XclExpFmlaCompImpl::IntersectTerm((anonymous namespace)::XclExpScToken, bool&) at sc/source/filter/excel/xeformula.cxx:1116:16 (instdir/program/libscfiltlo.so +0x3cc453d)
>  #6 in XclExpFmlaCompImpl::ListTerm((anonymous namespace)::XclExpScToken, bool) at sc/source/filter/excel/xeformula.cxx:1087:16 (instdir/program/libscfiltlo.so +0x3cc2b6f)
>  #7 in XclExpFmlaCompImpl::UnaryPreTerm((anonymous namespace)::XclExpScToken, bool) at sc/source/filter/excel/xeformula.cxx:1077:20 (instdir/program/libscfiltlo.so +0x3cc23a0)
>  #8 in XclExpFmlaCompImpl::UnaryPostTerm((anonymous namespace)::XclExpScToken, bool) at sc/source/filter/excel/xeformula.cxx:1056:16 (instdir/program/libscfiltlo.so +0x3cc121d)
>  #9 in XclExpFmlaCompImpl::PowTerm((anonymous namespace)::XclExpScToken, bool) at sc/source/filter/excel/xeformula.cxx:1043:16 (instdir/program/libscfiltlo.so +0x3cc0498)
>  #10 in XclExpFmlaCompImpl::MulDivTerm((anonymous namespace)::XclExpScToken, bool) at sc/source/filter/excel/xeformula.cxx:1030:16 (instdir/program/libscfiltlo.so +0x3cbf6e8)
>  #11 in XclExpFmlaCompImpl::AddSubTerm((anonymous namespace)::XclExpScToken, bool) at sc/source/filter/excel/xeformula.cxx:1017:16 (instdir/program/libscfiltlo.so +0x3cbe968)
>  #12 in XclExpFmlaCompImpl::ConcatTerm((anonymous namespace)::XclExpScToken, bool) at sc/source/filter/excel/xeformula.cxx:1004:16 (instdir/program/libscfiltlo.so +0x3cbdb98)
>  #13 in XclExpFmlaCompImpl::CompareTerm((anonymous namespace)::XclExpScToken, bool) at sc/source/filter/excel/xeformula.cxx:991:16 (instdir/program/libscfiltlo.so +0x3cbce58)
>  #14 in XclExpFmlaCompImpl::AndTerm((anonymous namespace)::XclExpScToken, bool) at sc/source/filter/excel/xeformula.cxx:974:16 (instdir/program/libscfiltlo.so +0x3cbba08)
>  #15 in XclExpFmlaCompImpl::OrTerm((anonymous namespace)::XclExpScToken, bool) at sc/source/filter/excel/xeformula.cxx:957:16 (instdir/program/libscfiltlo.so +0x3cba5b8)
>  #16 in XclExpFmlaCompImpl::Expression((anonymous namespace)::XclExpScToken, bool, bool) at sc/source/filter/excel/xeformula.cxx:934:20 (instdir/program/libscfiltlo.so +0x3c83a02)
>  #17 in XclExpFmlaCompImpl::CreateFormula(XclFormulaType, ScTokenArray const&, ScAddress const*, std::__debug::vector<XclExpRefLogEntry, std::allocator<XclExpRefLogEntry> >*) at sc/source/filter/excel/xeformula.cxx:505:24 (instdir/program/libscfiltlo.so +0x3c7f2f3)
>  #18 in XclExpFormulaCompiler::CreateFormula(XclFormulaType, ScRangeList const&) at sc/source/filter/excel/xeformula.cxx:2644:20 (instdir/program/libscfiltlo.so +0x3ca3801)
>  #19 in XclExpNameManager::InsertBuiltInName(char16_t, ScRangeList const&) at sc/source/filter/excel/xename.cxx:790:57 (instdir/program/libscfiltlo.so +0x3ed04ab)
>  #20 in XclExpNameManagerImpl::CreateBuiltInNames() at sc/source/filter/excel/xename.cxx:704:34 (instdir/program/libscfiltlo.so +0x3ec1794)
>  #21 in XclExpNameManagerImpl::Initialize() at sc/source/filter/excel/xename.cxx:390:5 (instdir/program/libscfiltlo.so +0x3ebf79e)
>  #22 in XclExpNameManager::Initialize() at sc/source/filter/excel/xename.cxx:771:13 (instdir/program/libscfiltlo.so +0x3ed1003)
>  #23 in XclExpRoot::InitializeGlobals() at sc/source/filter/excel/xeroot.cxx:260:22 (instdir/program/libscfiltlo.so +0x416962b)
>  #24 in ExcTable::FillAsHeaderXml(XclExpRecordList<ExcBundlesheetBase>&) at sc/source/filter/excel/excdoc.cxx:321:5 (instdir/program/libscfiltlo.so +0x3528545)
>  #25 in ExcDocument::ReadDoc() at sc/source/filter/excel/excdoc.cxx:725:17 (instdir/program/libscfiltlo.so +0x35414f7)
>  #26 in XclExpXmlStream::exportDocument() at sc/source/filter/excel/xestream.cxx:1106:18 (instdir/program/libscfiltlo.so +0x41ac136)
>  #27 in oox::core::FilterBase::filter(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) at oox/source/core/filterbase.cxx:497:55 (instdir/program/libooxlo.so +0x2b35d6c)
>  #28 in oox::xls::ExcelFilter::filter(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) at sc/source/filter/oox/excelfilter.cxx:238:27 (instdir/program/libscfiltlo.so +0x541148b)
>  #29 in SfxObjectShell::ExportTo(SfxMedium&) at sfx2/source/doc/objstor.cxx:2422:25 (instdir/program/libsfxlo.so +0x4b991c3)
>  #30 in SfxObjectShell::SaveTo_Impl(SfxMedium&, SfxItemSet const*) at sfx2/source/doc/objstor.cxx:1513:19 (instdir/program/libsfxlo.so +0x4b88f48)
>  #31 in SfxObjectShell::DoSaveAs(SfxMedium&) at sfx2/source/doc/objstor.cxx:1892:17 (instdir/program/libsfxlo.so +0x4b9b44e)
>  #32 in ScBootstrapFixture::saveAndReload(ScDocShell*, rtl::OUString const&, rtl::OUString const&, rtl::OUString const&, SfxFilterFlags) at sc/qa/unit/helper/qahelper.cxx:671:13 (workdir/LinkTarget/CppunitTest/../Library/libscqahelper.so +0x916a2)
>  #33 in ScBootstrapFixture::saveAndReload(ScDocShell*, int) at sc/qa/unit/helper/qahelper.cxx:693:28 (workdir/LinkTarget/CppunitTest/../Library/libscqahelper.so +0x939bf)
>  #34 in ScExportTest::testTdf112567() at sc/qa/unit/subsequent_export-test.cxx:4219:28 (workdir/LinkTarget/CppunitTest/libtest_sc_subsequent_export_test.so +0x2c0836)

Change-Id: I37582410068f2730d6f8dd0872b19fdfa8836c5c
Reviewed-on: https://gerrit.libreoffice.org/71766
Tested-by: Jenkins
Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst 3ff0c23b
...@@ -1874,8 +1874,8 @@ void XclExpFmlaCompImpl::ConvertRefData( ...@@ -1874,8 +1874,8 @@ void XclExpFmlaCompImpl::ConvertRefData(
sal_Int16 nXclRelCol = static_cast<sal_Int16>(rRefData.Col()); sal_Int16 nXclRelCol = static_cast<sal_Int16>(rRefData.Col());
rXclPos.mnCol = static_cast< sal_uInt16 >( nXclRelCol ) & mnMaxColMask; rXclPos.mnCol = static_cast< sal_uInt16 >( nXclRelCol ) & mnMaxColMask;
// convert row index (2-step-cast ScsROW->sal_Int16->sal_uInt16 to get all bits correctly) // convert row index (2-step-cast ScsROW->sal_Int32->sal_uInt32 to get all bits correctly)
sal_Int16 nXclRelRow = static_cast<sal_Int32>(rRefData.Row()); sal_Int32 nXclRelRow = static_cast<sal_Int32>(rRefData.Row());
rXclPos.mnRow = static_cast< sal_uInt32 >( nXclRelRow ) & mnMaxRowMask; rXclPos.mnRow = static_cast< sal_uInt32 >( nXclRelRow ) & mnMaxRowMask;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment