summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2018-08-15 16:48:09 +0200
committerStephan Bergmann <sbergman@redhat.com>2018-08-15 21:20:26 +0200
commit0d227c96e11d7d03829144183bc66d229e059a4b (patch)
tree5fcf459ec3d17e8630dc391cf4e4ced993ac2212 /editeng
parent6ede90a790ce08330af58f81474c103ee1ca438f (diff)
SvxNumberFormat::nAbsLSpace should have a larger type
...as is seen when executing CppunitTest_sd_filters_test with Clang's new -fsanitize=implicit-conversion (see below). The next larger natural choice after short is sal_Int32, and some of the code calling GetAbsLSpace actually already supported the value to be as wide (but not wider than) sal_Int32; code calling GetAbsLSpace that expected the value to be no wider than short has either been adapted or at least been marked with a TODO. (Other choices could have been sal_Int64 or long.) Some dependent function's parameter types have also been changed accordingly. > Testing file:///home/sbergman/lo/core/sd/qa/unit/data/ppt/pass/hang-10.ppt: [...] > filter/source/msfilter/svdfppt.cxx:3792:33: runtime error: implicit conversion from type 'sal_uInt32' (aka 'unsigned int') of value 144780 (32-bit, unsigned) to type 'short' changed the value to 13708 (16-bit, signed) > #0 in PPTNumberFormatCreator::ImplGetNumberFormat(SdrPowerPointImport const&, SvxNumberFormat&) at filter/source/msfilter/svdfppt.cxx:3792:33 (instdir/program/libmsfilterlo.so +0x7992cc) > #1 in PPTNumberFormatCreator::GetNumberFormat(SdrPowerPointImport const&, SvxNumberFormat&, unsigned int, PPTParaLevel const&, PPTCharLevel const&, TSS_Type) at filter/source/msfilter/svdfppt.cxx:3674:5 (instdir/program/libmsfilterlo.so +0x797c6d) > #2 in PPTStyleSheet::PPTStyleSheet(DffRecordHeader const&, SvStream&, SdrPowerPointImport&, PPTTextParagraphStyleAtomInterpreter const&, PPTTextSpecInfo const&) at filter/source/msfilter/svdfppt.cxx:4395:13 (instdir/program/libmsfilterlo.so +0x7ac38d) > #3 in SdrPowerPointImport::SdrPowerPointImport(PowerPointImportParam&, rtl::OUString const&) at filter/source/msfilter/svdfppt.cxx:1618:59 (instdir/program/libmsfilterlo.so +0x74762f) > #4 in ImplSdPPTImport::ImplSdPPTImport(SdDrawDocument*, SotStorage&, SfxMedium&, PowerPointImportParam&) at sd/source/filter/ppt/pptin.cxx:175:7 (instdir/program/libsdfiltlo.so +0x5f2be8) > #5 in SdPPTImport::SdPPTImport(SdDrawDocument*, SvStream&, SotStorage&, SfxMedium&) at sd/source/filter/ppt/pptin.cxx:162:23 (instdir/program/libsdfiltlo.so +0x5ce2bb) > #6 in ImportPPT at sd/source/filter/ppt/pptin.cxx:2760:47 (instdir/program/libsdfiltlo.so +0x617c79) > #7 in SdPPTFilter::Import() at sd/source/filter/sdpptwrp.cxx:106:32 (instdir/program/libsdlo.so +0x2878413) > #8 in sd::DrawDocShell::ConvertFrom(SfxMedium&) at sd/source/ui/docshell/docshel4.cxx:474:46 (instdir/program/libsdlo.so +0x2e165bc) > #9 in SfxObjectShell::DoLoad(SfxMedium*) at sfx2/source/doc/objstor.cxx:786:23 (instdir/program/libsfxlo.so +0x2c8cb12) > #10 in SdFiltersTest::load(rtl::OUString const&, rtl::OUString const&, rtl::OUString const&, SfxFilterFlags, SotClipboardFormatId, unsigned int) at sd/qa/unit/filters-test.cxx:75:31 (workdir/LinkTarget/CppunitTest/libtest_sd_filters_test.so +0x19771) > #11 in test::FiltersTest::recursiveScan(test::filterStatus, rtl::OUString const&, rtl::OUString const&, rtl::OUString const&, SfxFilterFlags, SotClipboardFormatId, unsigned int, bool) at unotest/source/cpp/filters-test.cxx:130:20 (workdir/LinkTarget/CppunitTest/../Library/libunotest.so +0x5724c) > #12 in test::FiltersTest::testDir(rtl::OUString const&, rtl::OUString const&, rtl::OUString const&, SfxFilterFlags, SotClipboardFormatId, unsigned int, bool) at unotest/source/cpp/filters-test.cxx:155:5 (workdir/LinkTarget/CppunitTest/../Library/libunotest.so +0x57ec9) > #13 in SdFiltersTest::testCVEs() at sd/qa/unit/filters-test.cxx:83:5 (workdir/LinkTarget/CppunitTest/libtest_sd_filters_test.so +0x19d6d) Change-Id: Ifa298a51bb62b7cbee9249b8289963f3427721f5 Reviewed-on: https://gerrit.libreoffice.org/59116 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/editeng/editdbg.cxx2
-rw-r--r--editeng/source/items/numitem.cxx11
-rw-r--r--editeng/source/outliner/outliner.cxx2
-rw-r--r--editeng/source/uno/unonrule.cxx2
4 files changed, 11 insertions, 6 deletions
diff --git a/editeng/source/editeng/editdbg.cxx b/editeng/source/editeng/editdbg.cxx
index 3a8232e4be34..51bf4a63498f 100644
--- a/editeng/source/editeng/editdbg.cxx
+++ b/editeng/source/editeng/editdbg.cxx
@@ -90,7 +90,7 @@ OString DbgOutItem(const SfxItemPool& rPool, const SfxPoolItem& rItem)
aDebStr.append('(');
aDebStr.append(static_cast<sal_Int32>(pFmt->GetFirstLineOffset()));
aDebStr.append(',');
- aDebStr.append(static_cast<sal_Int32>(pFmt->GetAbsLSpace()));
+ aDebStr.append(pFmt->GetAbsLSpace());
aDebStr.append(',');
if ( pFmt->GetNumberingType() == SVX_NUM_BITMAP )
aDebStr.append("Bitmap");
diff --git a/editeng/source/items/numitem.cxx b/editeng/source/items/numitem.cxx
index ae2c584ff83e..0001e6f1af6f 100644
--- a/editeng/source/items/numitem.cxx
+++ b/editeng/source/items/numitem.cxx
@@ -24,6 +24,7 @@
#include <com/sun/star/text/VertOrientation.hpp>
#include <com/sun/star/text/RelOrientation.hpp>
#include <editeng/brushitem.hxx>
+#include <o3tl/clamp.hxx>
#include <vcl/font.hxx>
#include <vcl/settings.hxx>
#include <editeng/editids.hrc>
@@ -197,7 +198,9 @@ SvxNumberFormat::SvxNumberFormat( SvStream &rStream )
rStream.ReadUInt16( nTmp16 ); cBullet = static_cast<sal_Unicode>(nTmp16);
rStream.ReadInt16( nFirstLineOffset );
- rStream.ReadInt16( nAbsLSpace );
+ sal_Int16 temp;
+ rStream.ReadInt16( temp );
+ nAbsLSpace = temp;
rStream.SeekRel(2); //skip old now unused nLSpace;
rStream.ReadInt16( nCharTextDistance );
@@ -259,7 +262,9 @@ void SvxNumberFormat::Store(SvStream &rStream, FontToSubsFontConverter pConverte
rStream.WriteUInt16( cBullet );
rStream.WriteInt16( nFirstLineOffset );
- rStream.WriteInt16( nAbsLSpace );
+ rStream.WriteInt16(
+ sal_Int16(o3tl::clamp<sal_Int32>(nAbsLSpace, SAL_MIN_INT16, SAL_MAX_INT16)) );
+ //TODO: better way to handle out-of-bounds value?
rStream.WriteInt16( 0 ); // write a dummy for old now unused nLSpace
rStream.WriteInt16( nCharTextDistance );
@@ -441,7 +446,7 @@ void SvxNumberFormat::SetPositionAndSpaceMode( SvxNumPositionAndSpaceMode ePosit
mePositionAndSpaceMode = ePositionAndSpaceMode;
}
-short SvxNumberFormat::GetAbsLSpace() const
+sal_Int32 SvxNumberFormat::GetAbsLSpace() const
{
return mePositionAndSpaceMode == LABEL_WIDTH_AND_POSITION
? nAbsLSpace
diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx
index 09397d45f6b6..186a1c17daca 100644
--- a/editeng/source/outliner/outliner.cxx
+++ b/editeng/source/outliner/outliner.cxx
@@ -1512,7 +1512,7 @@ tools::Rectangle Outliner::ImpCalcBulletArea( sal_Int32 nPara, bool bAdjust, boo
bool bOutlineMode = bool( pEditEngine->GetControlWord() & EEControlBits::OUTLINER );
// the ODF attribute text:space-before which holds the spacing to add to the left of the label
- const short nSpaceBefore = pFmt->GetAbsLSpace() + pFmt->GetFirstLineOffset();
+ const auto nSpaceBefore = pFmt->GetAbsLSpace() + pFmt->GetFirstLineOffset();
const SvxLRSpaceItem& rLR = pEditEngine->GetParaAttrib( nPara, bOutlineMode ? EE_PARA_OUTLLRSPACE : EE_PARA_LRSPACE );
aTopLeft.setX( rLR.GetTextLeft() + rLR.GetTextFirstLineOfst() + nSpaceBefore );
diff --git a/editeng/source/uno/unonrule.cxx b/editeng/source/uno/unonrule.cxx
index 3acef998e3d1..30c7deab2e94 100644
--- a/editeng/source/uno/unonrule.cxx
+++ b/editeng/source/uno/unonrule.cxx
@@ -245,7 +245,7 @@ Sequence<beans::PropertyValue> SvxUnoNumberingRules::getNumberingRuleByIndex(sal
aVal <<= static_cast<sal_Int16>(rFmt.GetStart());
pArray[nIdx++] = beans::PropertyValue(UNO_NAME_NRULE_START_WITH, -1, aVal, beans::PropertyState_DIRECT_VALUE);
- aVal <<= static_cast<sal_Int32>(rFmt.GetAbsLSpace());
+ aVal <<= rFmt.GetAbsLSpace();
pArray[nIdx++] = beans::PropertyValue(UNO_NAME_NRULE_LEFT_MARGIN, -1, aVal, beans::PropertyState_DIRECT_VALUE);
aVal <<= static_cast<sal_Int32>(rFmt.GetFirstLineOffset());