[Libreoffice-commits] .: chart2/source

Kohei Yoshida kohei at kemper.freedesktop.org
Thu Mar 3 18:55:45 PST 2011


 chart2/source/view/axes/TickmarkHelper.cxx |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

New commits:
commit a05213c822ed62256af12690abea62b12aa5dedd
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Thu Mar 3 21:54:52 2011 -0500

    Check for the value being outside the numeric limit of 32-bit int.

diff --git a/chart2/source/view/axes/TickmarkHelper.cxx b/chart2/source/view/axes/TickmarkHelper.cxx
index 2e1fcde..c7e58d3 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++)


More information about the Libreoffice-commits mailing list