summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2011-04-15 12:42:33 +0200
committerDavid Tardon <dtardon@redhat.com>2011-04-15 12:46:04 +0200
commitebc678510bb967957ca3baefbbdead517c8fc132 (patch)
treee203540154009686081c92c1a2c27a505d37803f /chart2
parentc3565154c1e1140af85aaa3472d5830f5f802be0 (diff)
check for the value being outside the numeric limit of 32-bit int
Apply the original commit a05213c822ed62256af12690abea62b12aa5dedd to the right file.
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/view/axes/Tickmarks_Equidistant.cxx9
1 files changed, 8 insertions, 1 deletions
diff --git a/chart2/source/view/axes/Tickmarks_Equidistant.cxx b/chart2/source/view/axes/Tickmarks_Equidistant.cxx
index 0273c9a678be..aa5376161853 100644
--- a/chart2/source/view/axes/Tickmarks_Equidistant.cxx
+++ b/chart2/source/view/axes/Tickmarks_Equidistant.cxx
@@ -31,6 +31,8 @@
#include "ViewDefines.hxx"
#include <rtl/math.hxx>
#include <tools/debug.hxx>
+
+#include <limits>
#include <memory>
//.............................................................................
@@ -214,7 +216,12 @@ sal_Int32 EquidistantTickFactory::getMaxTickCount( sal_Int32 nDepth ) const
if (!isFinite(fSub))
return 0;
- sal_Int32 nIntervalCount = static_cast<sal_Int32>( fSub / m_rIncrement.Distance );
+ double fIntervalCount = fSub / m_rIncrement.Distance;
+ if (fIntervalCount > std::numeric_limits<sal_Int32>::max())
+ // Interval count too high! Bail out.
+ return 0;
+
+ sal_Int32 nIntervalCount = static_cast<sal_Int32>(fIntervalCount);
nIntervalCount+=3;
for(sal_Int32 nN=0; nN<nDepth-1; nN++)