summaryrefslogtreecommitdiff
path: root/chart2/source
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2011-03-03 21:54:52 -0500
committerKohei Yoshida <kyoshida@novell.com>2011-03-03 21:55:38 -0500
commitc7a631d252f8def4aa2cddc43380bbb0f01424b1 (patch)
tree279eadbe3635593594a1279d3e5b40dcefe72f85 /chart2/source
parentf9f98386b2e98bae7d5177feb023ddb9ab452458 (diff)
Check for the value being outside the numeric limit of 32-bit int.
Diffstat (limited to 'chart2/source')
-rw-r--r--chart2/source/view/axes/TickmarkHelper.cxx8
1 files changed, 7 insertions, 1 deletions
diff --git a/chart2/source/view/axes/TickmarkHelper.cxx b/chart2/source/view/axes/TickmarkHelper.cxx
index 7ad0bcbf0cde..e45b2c6ec7f2 100644
--- a/chart2/source/view/axes/TickmarkHelper.cxx
+++ b/chart2/source/view/axes/TickmarkHelper.cxx
@@ -33,6 +33,7 @@
#include <rtl/math.hxx>
#include <tools/debug.hxx>
#include <memory>
+#include <limits>
//.............................................................................
namespace chart
@@ -481,7 +482,12 @@ sal_Int32 TickmarkHelper::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++)