summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-11-11 18:16:52 +0100
committerStephan Bergmann <sbergman@redhat.com>2016-11-14 17:45:17 +0100
commitc80ac2ba4a6486e6161e17f9118ba1563b7fc00e (patch)
tree36ef3e5b4e6b10db7df8ed004eb0f6760d831f76
parent2f0885bb364ba795cdda01a145dd88f1318b99b6 (diff)
Avoid -fsanitize=signed-integer-overflow
...when doing "Format - Page..." in Writer: > vcl/source/control/field.cxx:621:20: runtime error: signed integer overflow: 9223372036854775807 * 100 cannot be represented in type 'long' > #0 0x7f57787c4868 in NumericFormatter::Normalize(long) const vcl/source/control/field.cxx:621:20 > #1 0x7f578a4608dc in SetFieldUnit(MetricField&, FieldUnit, bool) svtools/source/misc/unitconv.cxx:75:32 > #2 0x7f5488952648 in SvxPageDescPage::SvxPageDescPage(vcl::Window*, SfxItemSet const&) cui/source/tabpages/page.cxx:275:5 > #3 0x7f54889c3ea4 in VclPtr<SvxPageDescPage> VclPtr<SvxPageDescPage>::Create<vcl::Window*&, SfxItemSet const&>(vcl::Window*&, SfxItemSet const&) include/vcl/vclptr.hxx:138:46 > #4 0x7f5488925d27 in SvxPageDescPage::Create(vcl::Window*, SfxItemSet const*) cui/source/tabpages/page.cxx:162:12 > #5 0x7f579ea86df4 in SfxTabDialog::ActivatePageHdl(TabControl*) sfx2/source/dialog/tabdlg.cxx:1085:24 > #6 0x7f579ea800e3 in SfxTabDialog::LinkStubActivatePageHdl(void*, TabControl*) sfx2/source/dialog/tabdlg.cxx:1035:1 > #7 0x7f5778b88f37 in Link<TabControl*, void>::Call(TabControl*) const include/tools/link.hxx:84:45 > #8 0x7f5778b44caa in TabControl::ActivatePage() vcl/source/control/tabctrl.cxx:1601:19 and NumericFormatter::mnMax is still SAL_MAX_INT64 (but will be set to a smaller value a few lines futher down in the SvxPageDescPage ctor). So initialize mnMax to a substantially smaller value (that is still "large", but avoids this kind of overflow), and hope that no code relies on the exact initial value. Change-Id: If3b4db1d20bc59418d1769e9690bc7ecdbf29a50
-rw-r--r--vcl/source/control/field.cxx4
1 files changed, 3 insertions, 1 deletions
diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx
index fe4d60cb00f5..ea91c0ef5d2d 100644
--- a/vcl/source/control/field.cxx
+++ b/vcl/source/control/field.cxx
@@ -504,7 +504,9 @@ void NumericFormatter::ImplInit()
mnFieldValue = 0;
mnLastValue = 0;
mnMin = 0;
- mnMax = SAL_MAX_INT64;
+ mnMax = SAL_MAX_INT32;
+ // a "large" value substantially smaller than SAL_MAX_INT64, to avoid
+ // overflow in computations using this "dummy" value
mnDecimalDigits = 2;
mnType = FORMAT_NUMERIC;
mbThousandSep = true;